Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index doesn't work with < or >

Status
Not open for further replies.

simplyroberto

Programmer
Apr 15, 2005
5
IT
I've noticed that MYSQL is not using indexes when the operators "<" or ">" are used in the SELECT query; For example:

SELECT firstname
FROM users
WHERE birthyear < 1969

Now, birthyear is of type "int" and is indexed. However the EXPLAIN statement shows that all rows are examined!

Can anyone explain why?

Many thanks,
Roberto
 
The MySQL optimiser has a mind of its own. Maybe in this case it has decided that it would be faster not to use an index.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top