From LEFT JOIN and RIGHT JOIN Optimization
The join optimizer calculates the order in which tables should be joined.
MySQL implements an
as follows:ALEFT JOINBjoin_condition
- Table
Bis set to depend on tableAand all tables on whichAdepends.- Table
Ais set to depend on all tables (exceptB) that are used in theLEFT JOINcondition.- The
LEFT JOINcondition is used to decide how to retrieve rows from tableB. (In other words, any condition in theWHEREclause is not used.)- All standard join optimizations are performed, with the exception that a table is always read after all tables on which it depends. If there is a circular dependence, MySQL issues an error.
- All standard
WHEREoptimizations are performed.- If there is a row in
Athat matches theWHEREclause, but there is no row inBthat matches theONcondition, an extraBrow is generated with all columns set toNULL.
