MySQL Forums
Forum List  »  Performance

order by using a multi-column key
Posted by: o s
Date: March 22, 2005 11:29AM

According to the mysql doc "How MySQL Optimizes ORDER BY":

"...The index can also be used even if the ORDER BY doesn't match the index exactly, as long as all the unused index parts and all the extra are ORDER BY columns are constants in the WHERE clause."

I have a pretty complex query with such a sort. When I put the unused index parts in the WHERE clause as constants, the query is fast; otherwise, it's noticeably slow.

The unintended side-effect is that the WHERE clause then filters out NULLs, which I want to be included.

Splitting the query into 2 UNIONS does work but it is slow on mysql 4.0.xx. On the new 4.1, the performance is good.

My question: is using a UNION the only workaround for this?

Thanks a lot.

Options: ReplyQuote

Written By
order by using a multi-column key
o s
March 22, 2005 11:29AM

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.