P
P
Puma Thailand2018-03-15 08:48:42
MySQL
Puma Thailand, 2018-03-15 08:48:42

How to make mysql use index for where in?

Actually at request select * from entries where a in (a1, a2, a3, a4)
In explain shows using where; using index, I would like to see only using index.
Accordingly, requests are executed for 10 seconds, despite the fact that there is a unique index on field a.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman MySQL, 2018-03-15
Tag

Sometimes MySQL does not use an index, even if one is available. One circumstance under which this occurs is when the optimizer estimates that using the index would require MySQL to access a very large percentage of the rows in the table. (In this case, a table scan is likely to be much faster because it requires fewer seeks.)

P
Papa, 2018-03-15
Stifflera @PapaStifflera

You can try index hints: https://dev.mysql.com/doc/refman/5.7/en/index-hint...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question