Subject Re: [firebird-support] query performance problem
Author Dimitry Sibiryakov
On 6 Apr 2004 at 18:30, Tobias Jenkner wrote:

>ALTER TABLE ITEM ADD PRIMARY KEY (ID);
>
>ALTER TABLE ITEM ADD CONSTRAINT FK317B1319BBD FOREIGN KEY (JOB)
>REFERENCES JOB (ID);
>ALTER TABLE ITEM ADD CONSTRAINT FK317B132AFA43C6 FOREIGN KEY
>(INDEXCLASS) REFERENCES INDEX_CLASS (ID);
>ALTER TABLE ITEM ADD CONSTRAINT FK317B13C3E6B25E FOREIGN KEY
>(FINISHEDSTEP) REFERENCES STEP (ID);
>
>CREATE INDEX FK317B1319BBD ON ITEM (JOB);
>CREATE INDEX FK317B132AFA43C6 ON ITEM (INDEXCLASS);
>CREATE INDEX FK317B13C3E6B25E ON ITEM (FINISHEDSTEP);
^^^^^^^^^^^^^^^^^^^^^^^^
These three indexes are superfluous. Drop them.

>CREATE INDEX FOO ON ITEM (JOB, FINISHEDSTEP);"

Depending on number of possible FINISHEDSTEP values this index
could decrease performance too.

>i execute the following query on this table:
>"select count(*), finishedStep from item where job=22 group by finishedStep"

Show us the query plan. To begin with...

SY, Dimitry Sibiryakov.