MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimizing Multiple ORDER BYs
Posted by: Rick James
Date: June 27, 2009 12:28AM

WHERE valid=1 AND language_ID=x ORDER BY linkval1 DESC, linkval2 DESC

Build a compound index. Start with the "=" fields in the WHERE clause: valid and language_ID (in either order). Then move onto the first thing in the ORDER BY: linkval1. It won't hurt to add linkval2; don't know whether it will help. Try this:
INDEX (language_ID, valie, linkval1, linkval2)
and then do EXPLAIN SELECT ... to see if it is using the index.

Options: ReplyQuote


Subject
Views
Written By
Posted
11460
June 25, 2009 07:50PM
Re: Optimizing Multiple ORDER BYs
3611
June 27, 2009 12:28AM


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.