MySQL Forums
Forum List  »  General

Order by slowing query
Posted by: Bruce Duncan
Date: October 14, 2004 09:41AM

I have the following query that runs quickly (0.5 secs):

select ZipListMatrix.ZipListMatrixID, ZipListMatrix.ZipID, ZipListMatrix.CarrierRouteID,ZipListMatrix.ListID, ZipListMatrix.Quantity,List.DisplayOrder
from ZipListMatrix
join List
join UserList on List.ListID = UserList.ListID
on ZipListMatrix.ListID = List.ListID
where UserList.UserInfoID = 869
and ZipListMatrix.ZipID = 23112
order by ZipListMatrix.ZipID

But as soon as I change the order by to "order by ZipListMatrix.ZipID, ZipListMatrix.ListID" the query runs very slow (7.5 secs).

The table ZipListMatrix has 3.3 million records. I have indexes on ZipID, ListID

When I do an "explain"...I see the dreaded: Using Temporary, Using Filesort

Can anyone help? I don't know what to do to speed up the query!

Options: ReplyQuote


Subject
Written By
Posted
Order by slowing query
October 14, 2004 09:41AM
October 14, 2004 01:25PM
October 14, 2004 02:59PM
October 14, 2004 03:11PM
October 15, 2004 08:37AM
October 15, 2004 08:40AM


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.