News for hackers. Stuff that matters.
Re:Query optimization in MySQL with Subqueries by IgorPartola on Friday February 11, 2011 @01:51PM (#2207634)
By definition all queries using JOINs can be re-written as sub-queries and vice versa. However, in some cases one is more intuitive, convenient or faster than the other. With MySQL you are better off with JOINs in most cases, and use subqueries only when there is a clear benefit and you understand why that would be faster. One exception to this is using a subquery with EXISTS, which is often way faster. While MySQL will tell you that it will look at all matching rows (when looking at EXPLAIN), it will only look at the first one it finds, so practically it ends up being faster.

There are no comments on this comment yet.