MySQL “IN” queries terribly slow with subquery but fast with explicit values

Subqueries execute every time you evaluate them (in MySQL anyway, not all RDBMSes), i.e. you’re basically running 7 million queries! Using a JOIN, if possible, will reduce this to 1. Even if adding indexing improves performance of those, you’re still running them.

Leave a Comment