MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimizing ORDER BY any ideas?
Posted by: Jay Pipes
Date: September 09, 2005 10:03PM

In the first, it is using an index *scan*, not seek, and is doing so because all columns needed by the query (for table T_PROPERTY) are in the T_PROPERTY.PRY_LNK_SALES_ORDER_ITEM index. In the one with the order by, no such covering index is used because the entrance of the T_PROPERTY.PRY_EXPORT_CITY field means that an index lookup from each record of the PRY_LNK_SALES_ORDER_ITEM index would need to be performed. MySQL judges this to be too expensive and so chooses to do a table scan instead (where it can already find the PRY_EXPORT_CITY field).

If you want both queries to be lightning fast, you may want to consider adding an extra index on (PRY_LNK_SALES_ORDER_ITEM, PRY_EXPORT_CITY)

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
4979
September 06, 2005 05:35PM
2774
September 06, 2005 06:39PM
2936
September 06, 2005 08:30PM
2700
September 06, 2005 09:18PM
2690
September 07, 2005 07:10AM
2654
September 07, 2005 06:28PM
2700
September 07, 2005 08:55PM
2537
September 08, 2005 08:28AM
2645
September 08, 2005 11:12PM
2637
September 09, 2005 10:00AM
2586
September 09, 2005 10:22AM
Re: Optimizing ORDER BY any ideas?
2586
September 09, 2005 10:03PM
2811
September 10, 2005 07:30AM
3197
September 10, 2005 09:22AM
2605
September 12, 2005 02:45PM
2531
September 12, 2005 04:41PM


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.