Hi,
I have a problem on SQL performance on PostgreSQL 7.1.3.
I have following tables.
create table tMailContentsF (
ContentsCD int8 not null,
primary key (ContentsCD),
FolderCD int8,
CONSTRAINT tMailContentsF_FolderCD
FOREIGN KEY(FolderCD)
REFERENCES tMailFolderF(FolderCD)
ON UPDATE CASCADE
ON DELETE CASCADE,
:
:
)
create table tMailFolderF (
FolderCD int8 not null,
primary key (FolderCD),
FolderName text
:
:
)
When I excute following SQL, the speed is very slow.
>explain select * from tMailContentsF where FolderCD = 1234;
So, I decided to create an index for FolderCD field.
>create index fordercd_idx on tMailContentsF(FolderCD);
>explain select * from tMailContentsF where FolderCD = '1234';
Since this is a foreign key, I might not need to create an index, however either ways doesn't work.
How can I speed up my SQL?