I'm looking into doing some query optimization and have a question regarding ordering of multiple indexes.
I know you can do indexes on multiple columns and that you have to match the order of the where clause with the index field order.
My question is about the ordering of the fields in the multi field index. For example if we had FirstName
and LastName
fields and we assume that LastName
is more unique than FirstName
, is there a benefit of doing the index in one ordering over the other?
E.g. Would an index of (LastName, FirstName)
be expected to perform better than an index of (FirstName, LastName)
or vise versa?
I heard from someone that you want to do the most narrowing item first in your where clauses, so if this is the case, I would assume we'd want the same in the indices, but I wish to confirm.