View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 09:44 AM
Joachim Durchholz
 
Posts: n/a
Default Re: Join vs subselect

André Hänsel schrieb:
> Hi,
>
> is there a difference in performance between
> SELECT a.* FROM a INNER JOIN b USING (some_key)
> and
> SELECT * FROM a WHERE EXISTS (SELECT * FROM b WHERE a.some_key =
> b.some_key)
> ?


Likely. The mysql optimizer doesn't try to optimize things that you
could write more efficiently by yourself (at least that's what I read
between the lines of the docs and guiding principles of the optimizer
design - I may be wrong).
Try EXPLAIN <sql-statement> for each of the two statements; if the
results are the same, the optimizer will be equally efficient (or
inefficient, as the case may be); if they are different, you most likely
will have performance differences.

HTH
Jo
Reply With Quote