Subject | Re: need help on optimization |
---|---|
Author | Michael Vilhelmsen |
Post date | 2005-04-25T08:28:05Z |
> >And a query like:read
> > select distinct "id" from mytable
> >or:
> > select "id" from mytable group by "id"
> >also takes around five minutes, even though it says it is using
> >the index created on "id".
>
> The first query can't use an index. In the second, to determine
> "distinctness", without any limiting WHERE clause, it's necessary to
> the whole table.Does this also include the usage of MAX ?
>
> >It appears that firebird is
> >searching over every row in the table, and isn't just using
> >the information in the index to construct the result.
>
> In the first two cases, it does have to read every row. How would you
> suppose an index could be used ?
>
I.e. If I want to have
Select
Max(MyDate)
from MyTable
And there is an index defined using date.
Will it still not use the index ?
And why not ?