Answer the question
In order to leave comments, you need to log in
MySQL Composite Index Sampling
sqlinfo.ru/forum/viewtopic.php?id=151
The link above says that the WHERE query can only be executed on the left side of the composite key, i.e. on the first element.
Please tell me why is that? And why can't it be used on the right side?
Answer the question
In order to leave comments, you need to log in
The query can be run on any part of the key, but indexes will only work on the left side. That is, for KEY(f1, f2, f3) indexes will work when searching by WHERE f1=xx AND f2=xx AND f3=xx
, WHERE f1=xx AND f2=xx
or WHERE f1=xx
. If you need to speed up the search for another part of the key (for example WHERE f2=xx
, then you need to build a separate index.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question