Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • The MySQL docs state pretty plainly that subqueries have not been optimized at all and won't be until the 6.0 release. In the meantime, you have to pay attention to how you use them. The xaprb.com stuff is a good resource.

    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.