NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Optimizing subqueries (Score:1)
In most cases, it works out best to use derived tables (subqueries in the FROM clause), which are implemented with a temporary table and force the evaluation of the subquery before the JOIN order is determined. The only situation where this can be a negative is when you use LIMIT, since those queries are often handled without needing to evaluate the entire subquery.
In situations where you can use a JOIN or LEFT JOIN instead of a correlated subquery, you should. Replacing NOT EXISTS queries with a LEFT JOIN is usually a big improvement.
If you have specific queries you need help with, post them on the MySQL list. I read it and sometimes help people with queries, but usually someone else beats me to it.
Reply to This