MySQL Forums
Forum List  »  Newbie

Removing Using temporary; Using filesort from a range query
Posted by: S J
Date: August 24, 2009 11:47AM

MySQL v5.1.3
i int(11) unsigned auto_increment
type tinyint(1) unsigned
rating smallint(3)
status tinyint(1) unsigned
lang char(2)
time int(10) unsigned

Typically what I need to do looks like the query below. The rating range can be customised on a per-user basis and there are unrelated considerations, so farming out results to a cache is not possible. The time field is a Unix timestamp and preferably needs to be accommodated as a range as well, but I'm happy to leave it out for now unless it's particularly easy to deal with.

WHERE lang = "en"
AND (type = 0 OR type = 1 OR type = 2) 
AND (status = 0 OR status = 1)
AND rating >= 0
GROUP BY i
ORDER BY rating DESC
LIMIT 0, 20

Or ORDER BY i DESC. I cannot improve upon "Using where; Using temporary; Using filesort", although I am not familiar with much more than basic keys and queries.

Thanks for your help.



Edited 3 time(s). Last edit at 08/24/2009 12:22PM by S J.

Options: ReplyQuote


Subject
Written By
Posted
Removing Using temporary; Using filesort from a range query
S J
August 24, 2009 11:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.