Do mysql aggregate indexes make some other indexes completely redundant?

If I have a composite index on (a, b), I understand that queries related only to 'a' will still use the composite index (but not queries related to 'b')

My question is, is there any reasonable reason to have an index with one column on 'a' if I have an index (a, b)? What I read seemed vague as to whether the index (a, b) is a complete replacement for a, or just the “better than nothing” index.

This assumes that I am filtering both a and a, b. I have a table with too many indexes that degrades write performance and wants to double check before dropping indexes, which I'm only sure are of no use.

Also, does this answer vary depending on whether I use InnoDb or MyISAM? The corresponding table is MyISAM, but most of our tables are InnoDb.

+5
source share
2 answers

Your index (a, b) also handles queries containing only "a", and there is no need for an index only for (a).

From the documentation :

index, .

, (col1, col2, col3), (col1), (col1, col2), (col1, col2, col3).

+4

, - 'a', (a, b)?

, (a), (a, b)

+2

All Articles