Why search by date field requires engine to touch all records? Is there any way to avoid it?
Following query
EXPLAIN select * FROM playdays where realdate>=Date('2010,01,01') ;
shows that amount of rows required to generate the result is 2725 which is higher than total amount of records in the table (2349).
Question #1: Why amount of rows to touch is higher than amount of records?
Question #2: Why amount of rows to touch is so high even though there is an index on the 'realdate' field? Is that really means query will touch all records? Should I optimize it? If yes, how?
Please advise! Any feedback is welcome! Thank you!
P.S. I use MYSQL 5.1.43 version, my table has realdate field, its type is 'DATE', table has totally 2349 records.
P.P.S. Answering to one of comments: selecting only realdate field reduces amount of touched records to 1362... if I vary date value used in search, amount of touched records changes depends of amount records left in the selections...
Hope, that additional information will help.
realdate
field,the query will not touch all records,so you need [Multiple-Column Indexes][2] [1]: dev.mysql.com/doc/refman/5.0/en/… [2]: dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.htmlrealdate
?