MySQL Forums
Forum List  »  Performance

Multi-Column indexes
Posted by: Michael Preiss
Date: October 08, 2011 06:45PM

Hello forum,

this has been bothering me for a while and I just cant seem to get a definitive answer.

Let's assume I have a table like this:
Col_A
Col_B
Col_C
Col_D
INDEX(Col_A,Col_B,Col_C,Col_D)

Now this obviously works great if columns A,B,C,D or A,B,C or A,B OR A are used in the where clause.

But what happens if I have to omit say column C because what I want to achieve would be "give me the rows where A=x, B=y, and D=z, regardless of the value of C".

Do I need a second index like INDEX(Col_A,Col_B,Col_D) or is mysql smart enough to figure it out?

Thanks in advance for your help.

/edit
fixed thread title. oops.



Edited 1 time(s). Last edit at 10/09/2011 10:55AM by Michael Preiss.

Options: ReplyQuote


Subject
Views
Written By
Posted
Multi-Column indexes
2620
October 08, 2011 06:45PM
740
October 09, 2011 10:56AM
892
October 09, 2011 11:55AM
704
October 09, 2011 12:10PM
712
October 09, 2011 02:40PM
724
October 11, 2011 09:25PM
773
October 12, 2011 12:04AM
646
October 14, 2011 10:02PM


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.