On Tue, Aug 18, 2009 at 5:08 AM, Simon Kimber<simon@stripped> wrote:
> I have indexes on siteid, datestamp and msgtype.
> Queries such as the following are constantly appearing in the slow
> queries log:
> SELECT * FROM enquiries WHERE siteid = 59255 AND msgtype = 0 ORDER BY
> datestamp DESC LIMIT 5;
Read the explanation of ORDER BY optimization:
As it explains, you aren't providing a key it can use. If you create
a multi-column index on siteid, msgtype, and datestamp, that will
probably fix it.