MySQL Forums
Forum List  »  Performance

Re: tactics to improve ORDER BY and LIMIT (different question)
Posted by: Rick James
Date: March 03, 2009 08:26PM

Your query looks like dozens of others I have seen. Yours is among the simplest; wait til you add a join, other tests, pagination, etc.

For now...
Consider removing un-approved items. You could put them into a similar table and use UNION for the few cases where you need to see both the approved and unapproved items at once.

Ok, you don't want to go to that much trouble. Here's something that might work in your simple case:
INDEX foo(status, created_at)
and do
... FROM posts USE INDEX(foo)

"216833" is bogus -- that does not take into account your LIMIT, nor does it give you a clue of whether it will stop short. Suggest you do actual timings rather than depending just on EXPLAIN.

If these ideas don't suffice, need more info: please provide
* SHOW CREATE TABLE tbl\G
* SHOW TABLE STATUS LIKE 'tbl'\G
* EXPLAIN SELECT ...\G
and surround them with [ code ] and [ / code ]

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: tactics to improve ORDER BY and LIMIT (different question)
1965
March 03, 2009 08:26PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

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.