> If you does the query in the same order, the primary's key index is used. By
> example:
...
> - title, start_date, username     ---> don't use the primary's key index
> because the column "username" is not the first column.

I find this a strange example. Sure, if you have

SELECT <whatever>
FROM MyTitle MT
JOIN MyMainTable MMT 
  ON MT.Title = MMT.Title
LEFT JOIN MyUserName MUN
       ON MMT.UserName = MUN.UserName
WHERE MMT.Start_Date = '9.9.2011'

then your example is very true, the MyUserName table has to be after 
MyMainTable in the plan, and hence, our index in question cannot be used. 
However, the order of the fields in

SELECT <whatever>
FROM MyMainTable
WHERE title = 'Red Nose of Courage'
  AND Start_Date = '9.9.1991'
  AND UserName = 'Firebird'

should be irrelevant. Of course, order matters if you're talking about using an 
index in ORDER BY, but indexes are generally great for limiting rows through 
selection (WHERE) or linking (JOIN) and not very useful for ordering a result 
set (it might be different for desktop databases, but with client/server 
databases I think you always ought to return only records that you're actually 
going to use).

Set

Reply via email to