Subject Re: [firebird-support] Re: need help on optimization
Author Helen Borrie
At 08:28 AM 25/04/2005 +0000, Michael Vilhelmsen wrote:

> >
> > In the first two cases, it does have to read every row. How would you
> > suppose an index could be used ?
> >
>Does this also include the usage of MAX ?
>I.e. If I want to have
> Max(MyDate)
>from MyTable
>And there is an index defined using date.
>Will it still not use the index ?

Now, does one answer Yes or No to that question? :-))

Yes, it will use an index and, if you have only an ascending index on
MyDate, it will be worse than walking the set. Define a DESC index on any
column that you are likely to want to do a MAX() on, across a large
set. Then the result will be instantaneous. Apply a similar index
strategy to any columns on which you are going to do a GROUP BY DESC or an
ORDER BY DESC) on a large set.

> And why not ?

"Two men looked out through prison bars:
One saw mud and the other saw stars."