Subject Re: Not using index for MAX
Author Adam
--- In firebird-support@yahoogroups.com, "Erick Sasse" <esasse@...> wrote:
>
> Ok, but I don't get it. Can't it just get the last record in the
> index? Isn't it as easy as use a descending index?

Bidirectional indices take up more space and so must be less dense
than unidirectional indices. Having larger indices means that you have
more sparse index pages and reading the index to will take longer.

Also, don't assume the highest record in the index equals the max, the
highest record may belong to an uncommitted transaction, or your
transaction isolation properties may otherwise prevent you from
reading it.

If you want to run select max(), give Firebird a descending index on
that field.

Adam