Subject Re: [firebird-support] slow select max() query
Author Helen Borrie
At 05:22 AM 10/03/2009, you wrote:
>Firebird 2.1.1
>Query: select max(ID) from TABLE where FIELD=4
>Runs quite slowly. Apparently it scans whole index.
>When changed to "min" - it runs immediately.
>I have both indices:
>create index IDX1 on TABLE(FIELD)
>create descending index IDX2 on TABLE(FIELD)
>Am I missing something fundamental here? I always thought descending index
>should do the thing...

If the descending index is on the column that is being evaluated by MAX(), yes. Your IDX2 doesn't help at all.