MySQL Forums
Forum List  »  Optimizer & Parser

Re: ORDER BY doesn't use index
Posted by: Toa Sty
Date: October 03, 2006 02:38AM

That's odd. Based on that explain plan, that query should still take the same order of magnitude of time as your first attempt, as it's having to find 538,427 rows using the status index then filesort them to find the top 90 with the lowest req_ids. It's still using the same index as before too ('status').

It takes a few seconds to run, right?


I still think a multi-column index on (status, req_id) would allow this query to return near-instantly for you.

i.e.
alter table requester add index toastyindex(status, req_id);
alter table requester drop index status;    -- you dont need it any more as the toastyindex covers the status column.
analyze table requester;
explain SELECT req_id FROM requester WHERE status='1' ORDER BY req_id ASC LIMIT 0,90;

What does this plan look like? You sure it doesn't help?

Cheers,
Toasty

-----------------------------------------
email: 'toasty'*3 at gmail

Options: ReplyQuote


Subject
Views
Written By
Posted
12183
September 13, 2006 12:32AM
5368
September 13, 2006 02:00AM
3888
September 13, 2006 02:36AM
3522
September 27, 2006 03:39AM
3399
September 27, 2006 05:02AM
3303
September 30, 2006 05:53PM
Re: ORDER BY doesn't use index
3299
October 03, 2006 02:38AM


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.