Subject Re: [firebird-support] Slow select min()
Author Doug Chamberlin
Kirill Nesterenko wrote:
> I have a query which runs very slow:
> select min(id) from stat where user_id = 100
>
> [snip]
>
> also if I run select max(id) - it runs immediately.

Here's a piece of info that looks relevant:

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!