"what query will be the fastest?" Code Answer


although there are always exceptions, option 3 is almost surely the best/first choice. depending on your indexes and data distributions, the mysql query execution planner will handle which order to pull from the tables.

in the other cases, subqueries (options 1 and 2) are executed for every row of the outer query -- they can be terribly inefficient. so, following the previous statement, nested subqueries (option 1), can be exponentially worse than using first order subqueries (option 2) or normal joins (option 3).

note that for inner joins, it doesn't matter with respect to performance or functionality if the extra conditions are in the join clauses or in the where clauses. consequently, your other option is effectively equivalent to the option 3.

By coxc on February 9 2022

Answers related to “what query will be the fastest?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.