In answer to this SQL question, I\'ve encountered a statement that fixed-value IN()
operator is much slower than INNER JOIN
with the same content,
This relates to the length of the IN clause - and what is sometimes called a BUG in MySQL.
MySQL seems to have a low threshold for IN clauses, when it will swap to a TABLE/INDEX SCAN instead of collecting multiple partitions (one per IN item) and merging them.
With an INNER JOIN, it is almost always forced to use a direct row-by-row in JOIN collection, which is why it is sometimes faster
Refer to these MySQL manual pages
I could be wrong since it seems to imply that IN (constant value list)
should always use a binary search on each item...