Monday, April 16, 2012

Any tips to improve MySQL query?

I have a table with 500K rows that looks like this: http://d.pr/njFJ



enter image description here



A query like this sometimes often takes more than 2 seconds:



SELECT * 
FROM `alerts`
WHERE `a_timestamp` > '2012-04-15' AND `a_timestamp` <= '2012-04-16'
AND a_company_id IN(64,65,69,70,71,72,73,74,75,76,83,86,106,108,109,116,148) ORDER BY a_id DESC


Here's the explain query: http://d.pr/z20b



enter image description here



Can somebody point out what I'm doing wrong? Maybe I'm missing something. Should it take that much time on such a small table?





No comments:

Post a Comment