A
A
Archont122014-01-23 20:06:49
MySQL
Archont12, 2014-01-23 20:06:49

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

1 answer(s)
R
Rsa97, 2014-01-23
@Archont12

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=xxor 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 question

Ask a Question

731 491 924 answers to any question