Posted by Alexander Kuznetsov on 06/09/06 21:09
>
> select * from tblnames where firstname = 'john'--Performed a Table Scan
>
If you only select 2 columns, firstname, lastname
select columns, firstname from tblnames where firstname = 'john'
and the table has a lot of other columns, the index is likely to be
used even if firstname is not the first column in the index. The reason
is simple: the index contains all the information necessary to satisfy
the query and it is smaller than the table.
[Back to original message]
|