Subject Re: [firebird-support] Not using index for MAX
Author Erick Sasse
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?

--
Erick Sasse


2007/10/26, Alexandre Benson Smith <iblist@...>:
> Erick Sasse wrote:
> > If I have a integer PK and do a "SELECT MAX(MY_PK_FIELD) FROM MYTABLE"
> > it doesn't use the index to find the max value, why?
> >
> > Thanks.
> >
> >
> Because you have an ASCENDING index on MY_PK_FIELD, create a DESCENDING
> index on MY_PK_FIELD and it would be used.
>
> see you !
>
> --
> Alexandre Benson Smith
> Development
> THOR Software e Comercial Ltda
> Santo Andre - Sao Paulo - Brazil
> www.thorsoftware.com.br
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>