MySQL Forums
Forum List  »  Optimizer & Parser

Re: INNER JOIN (WHERE) vs LEFT JOIN
Posted by: Sergey Petrunya
Date: November 03, 2005 05:18AM

Veny wrote:
> Could anyone point me a reference on information
> related to JOIN operations?
> E.g. if i wrote the following sql:
> SELECT * FROM Table1, Table2 WHERE Table1.columnA
> = Table2.columnB AND Table1.columnA = 5;
>
> Does MySQL filters all record of Table1 with
> columnA's value equals to 5, and then perform
> JOIN? Or JOIN is perform first before filtering
> out the values?

It depends on which access method is used. If Table1 is accessed using
ALL/index/range/ref(const) access method, then filtering on "Table1.columnA = 5" will
be performed before doing join with Table2.

If Table1 is accessed using ref access method on "Table1.columnA = Table2.columnB"
(suppose there is an index on Table1.columnA) then the join is performed first.

Sergey Petrunia, Software Developer
MySQL AB, www.mysql.com
My blog: http://s.petrunia.net/blog

Options: ReplyQuote


Subject
Views
Written By
Posted
88426
November 02, 2005 08:12PM
Re: INNER JOIN (WHERE) vs LEFT JOIN
24987
November 03, 2005 05:18AM
24812
November 03, 2005 05:26AM


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.