Monday, November 5, 2012

Is left-join faster then inner join?

LEFT JOIN and INNER JOIN are different things. You cannot compare them.

If you write an INNER JOIN as LEFT JOIN you will either end up with
different results or - if you filter the NULL rows of the LEFT JOIN -
there is good chance for the LEFT JOIN to be slower. Because:

- the LEFT JOIN creates extra intermediate data (the NULL rows for
unmatched rows from the left table) that is thrown away later

- the optimizer has less freedom to optimize the LEFT JOIN

No comments:

Post a Comment