[thelist] mysql index not being used in query

Sarah Sweeney mr.sanders at designshift.com
Mon May 9 15:16:04 CDT 2005


I have a table called "Cats" with the following fields (other fields 
omitted to simplify):

CategoryID
NodeLeft
NodeRight
Title

I've added indexes on

CategoryID -> CatID
NodeLeft, NodeRight -> NodeLR

I ran this EXPLAIN statement:

EXPLAIN SELECT CategoryID, Title, NodeLeft, NodeRight
           FROM Categories
          WHERE NodeLeft BETWEEN 2 AND 1705
       ORDER BY NodeLeft

which returned the following:

table | type | possible_keys | key    | key_len | ref    | rows | Extra
------+------+---------------+--------+---------+--------+------+----------------------------
Cats  | ALL  | NodeLR        | (NULL) | (NULL)  | (NULL) | 852  | Using 
where; Using filesort

I'm not really sure why the query isn't using the NodeLR index - any ideas?


More information about the thelist mailing list