Aaron Fi
Aaron Fi

Reputation: 10406

Does a MySQL index on columns (A,B,C) optimize for queries than just select/order by (A,B) only?

Given a table with columns A,B,D,E,F. I have two queries:

I want to add an index on (A,B,C) to speed up the second query. I'm thinking this will also speed up the first query. Is that correct? Or should I add a second index on (A,B)?

Or am I oversimplifying the problem of performance-tuning here?

Upvotes: 1

Views: 114

Answers (1)

Tom
Tom

Reputation: 9653

Just put an index on all three of them. You don't need a second index.

Upvotes: 1

Related Questions