MySQL Forums
Forum List  »  Optimizer & Parser

Re: (How) are subqueries optimized involving the same table?
Posted by: Bob Field
Date: July 13, 2006 08:12AM

Prefix the query with EXPLAIN and you will get back a resultset detailing what operations are performed. Personally I would expect caching to be a benefit here since it is the same row returned each time.

I think you'd be better off with something like this:

SELECT t1.foo, t1.field1, t1.field2, t1.field3
FROM t1
JOIN t2 ON t2.id = 123
WHERE t1.id = 7;

Or even:

SELECT field1, field2, field3 INTO @f1, @f2, @f3 FROM t2 WHERE id = 123;
SELECT foo, @f1, @f2, @f3 FROM t1 WHERE id = 7;

(Assuming the same connection, i.e. not from Query Browser)



Edited 1 time(s). Last edit at 07/13/2006 08:13AM by Bob Field.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: (How) are subqueries optimized involving the same table?
1949
July 13, 2006 08:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.