MySQL Forums
Forum List  »  Performance

Re: Slow Query stuck on "Sending Data"
Posted by: Rick James
Date: February 11, 2011 08:00PM

To build the 'perfect' index, do the following:
1. Start with all fields that are '=' some constant.
2. Add on one more thing - a range, group by, or order by.
3. Anything after that is ignored.

Therefore, (`country`,`state`,`city`,`visible`,`listing_date`,`category`,`property_type`)
stopped after listing_date, and could not take advantage of the last two fields.

This would have worked better:
(`country`,`state`,`city`,`visible`,`category`,`property_type`,`listing_date`)
assuming all 6 of the first 6 fields were in WHERE with '='. (The 6 could be in any order.)

So, why did
(`country`,`state`,`city`,`visible`,`listing_date`)
work so well? I suspect it did not. Instead, the freshly rebuild table (due to changing the indexes) was cleaner and/or better cached.

Options: ReplyQuote


Subject
Views
Written By
Posted
12693
January 31, 2011 09:59PM
4436
February 02, 2011 12:40AM
2769
February 02, 2011 09:12AM
3450
February 02, 2011 09:18PM
2583
February 03, 2011 12:35AM
1867
February 03, 2011 08:00AM
1701
February 11, 2011 02:19PM
1925
February 11, 2011 03:28PM
Re: Slow Query stuck on "Sending Data"
2174
February 11, 2011 08:00PM
2047
February 11, 2011 08:15PM


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.