MySQL is capable of using indices with IN
.. now, is MySQL using indices in the particular query? Well, ask the query planner!
In this case an index over (column1, column2, ..)
could be used - because all the leftward components have been satisfied. That is, an index seek could be done on column1 (for =
), and then column2 (for IN
). But again, ask the query planner as unexpected plans are not unheard of; just because the query planner could choose an index doesn't mean that it will.
See EXPLAIN, for how to ask:
When EXPLAIN is used with an explainable statement, MySQL displays information from the optimizer about the statement execution plan. That is, MySQL explains how it would process the statement, including information [like index usage] about how tables are joined and in which order ..
.. With the help of EXPLAIN, you can see where you should add indexes to tables so that the statement executes faster by using indexes to find rows.