Sql – Outer JOIN vs Inner JOIN

sqlsql-server-2008

I have always thought that Inner Join performs better than Outer JOIN, but I've experienced several cases now where this simply isn't true…

The other day I was creating a query with a series of INNER JOINS. Inner join was appropriate for all these joins as I only wanted rows matched in all joined tables.

I noticed that performance was very bad (1 min to run the query). The weird thing was that when I switched a few of them to Outer JOINs the query finished in a few seconds…
It's not a case of warm up or caching because I restarted the SQL server in between runs, and the performance readings were consistent over time.

I experienced this same situation on two different reports, but the common theme was that performance was improved by switching to LEFT JOIN. I made the switch for the same tables for both reports. All JOINS were done ON GUID columns

Left JOIN gave the same number of rows since all ids were matched in the JOINED tables, so it was ok to switch, but I am curious if anyone has an explanation.
Any advice on this?

The platform was SQL Server 2008 and all outer JOINS were LEFT JOINS

Best Answer

The inner join is faster than left join.

This answer should give you some tips.