MySQL Forums
Forum List  »  Performance

Re: slow queries using multi-column index
Posted by: Harrison Fisk
Date: March 03, 2005 07:36PM

Hi,

With the way that MySQL uses multi-column indexes, you should always have the = columns as the leftmost prefix.

So with your WHERE clause of:
photo > -2 and APPDOMAIN_ID = 0 and COUNTRY = 'DE' and REGISTERED > date_sub(curdate(), interval 7 day)

You should have an index as either:

(APPDOMAIN_ID, COUNTRY, photo)

or

(APPDOMAIN_ID, COUNTRY, REGISTERED)

Either of those should give a performance increase. If not please give the EXPLAINs of the query with both of those indexes and the original setup.

Harrison Fisk, Trainer and Consultant
MySQL AB, www.mysql.com

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: slow queries using multi-column index
1835
March 03, 2005 07:36PM


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.