This is my experience with MSSQL so please test with MySQL
Consider a composite index on (col1, col2, col3)
You get an index seek on:
col1
col1 & col2
col1 & col2 & col3
On col2 and col3 you can get an index (not table) scan.
Since the index is smaller than the table this can help search times.
Some times this is a significant impact.
A search on col1 and col3 would (hopefully) be an index seek on col1 and an index scan on col3.
And note if the table is small you will just get some default plans
Need to load up with some data to test
col1. Sincecol2isn't being used,col3will force a table scan on whatever records have the matchingcol1. It's better than not having an index, but not as good as having full-coverage index.(col1, col3). Only on(col1)(which will be used for part of the lookup on(col1, col3)).col1matches will be "fast" since the index can be used, butcol3will have to scan the individual rows found by thecol1match. so... partial table scan.col1live in the same or adjacent blocks. This has real-world repercussions, if there are only a few values ofcol2a.o.t. many values ofcol1