Subject | Re: [firebird-support] Slow select min() |
---|---|
Author | Doug Chamberlin |
Post date | 2009-07-29T00:35:56Z |
Kirill Nesterenko wrote:
Firebird indexes are "one-way" indexes. An ascending index can quickly
find a maximum value but not a minimum value.
So, to make your first query run as fast as the other one, it looks like
you need to create a descending index on the ID field. Try it!
> I have a query which runs very slow:Here's a piece of info that looks relevant:
> select min(id) from stat where user_id = 100
>
> [snip]
>
> also if I run select max(id) - it runs immediately.
Firebird indexes are "one-way" indexes. An ascending index can quickly
find a maximum value but not a minimum value.
So, to make your first query run as fast as the other one, it looks like
you need to create a descending index on the ID field. Try it!