tags:

views:

16

answers:

1

This may be a stupid question but I can't help asking, just to verify.

According to mysql document,

If you have a 4-column index on (col1, col2, col3, col4), you have indexed search capabilities on (col1), (col1, col2), (col1, col2, col3) and (col1, col2, col3, col4).

My question is, how about (col1, col3, col4) or (col1, col2, col4)??

+1  A: 

As you said,

(col1, col3, col4) : Only for col1
(col1, col2, col4) : Only for col1, col2

Take a look at Multiple-Column Indexes and How MySQL Uses Indexes

Edit: Oh.. And by the way, EXPLAIN EXTENDED SELECT ... Lets you see what indexes MySQL will be using for a query.

simendsjo
How sad. That means I'll need an index for (col1, col2, col3, col4) and another index for (col1, col3, col4)
Eric Sim
+1, note:while you are editing could you fix your links
Unreason
Whats wrong with the links? Works here..
simendsjo
@Eric: I know. It's not unusual that the indexes for a table can exceed the size of the data itself
simendsjo