I am trying to optimize the following query as it is taking an extremely long time to execute. Can anyone provide any advice on how to optimize this and can they recommend any indexing that would speed it up. As a note the edata table contains around 1 million rows and the ddata table has around 15 million rows. There are around 5,000 items selected from ddata if you run the query
SELECT * FROM ddata WHERE DATE(startDate) = DATE(NOW());
The query that I am trying to optimize is:
SELECT e.ID,e.uID,e.sID
FROM edata e
LEFT JOIN ddata d ON e.sID=d.sID
WHERE DATE(d.startDate)=DATE(NOW());
Thanks
where,join, and sometimesorderclauses. Note that having an index on a field isn't of any use if you're using values DERIVED from that field in the comparison, like you are with your DATE() calls.startDatemight be indexed, but something likemd5(somefield)will force a table scan.