|  | Posted by Alexander Kuznetsov on 06/09/06 03:14 
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 = ...
 >
 
 Not necessarily. Consider the following query:
 
 select lastname, firstname from some_table where firstname = ...
 
 It will use the index, and, more to the point, it will not touch the
 table at all - the index already has all the information the query
 needs. It is called "index covering".
  Navigation: [Reply to this message] |