Posted by ZeldorBlat on 06/09/06 00:03
Baihao Yuan wrote:
> Hi,
>
> I created a composite index (lastname, firstname). I know the following
> queries will use this index:
>
> WHERE lastname = ...
> WHERE lastname = ... AND firstname = ...
>
> Also this won't use the index:
> WHERE firstname = ...
>
> But how about: WHERE firstname = .. AND lastname = ...
It will use the index.
>
> And why?
Because, as far as the query optimizer is concerned, these two are
exactly the same:
WHERE lastname = ... AND firstname = ...
WHERE firstname = ... AND lastname = ...
[Back to original message]
|