Subject Re: [firebird-support] Slow select min()
Author Dmitry Yemanov
Kirill Nesterenko wrote:

> Also, I noticed that default plan is
> "PLAN (stat ORDER PK_STAT INDEX (STAT_USER_ID))".
> But if I change it to the "PLAN (stat INDEX (STAT_USER_ID))" - query runs
> immediately..

An obvious example of a bad optimizer choice. With the default plan, the
engine scans the whole index PK_STAT and trying the appropriate record
IDs against the bitmap created as a result of the range index
(STAT_USER_ID) scan. I suspect the two records with USER_ID = 100 have
quite large ID values (i.e. they're located near the end of the index),
thus you notice the bad performance.


Dmitry