What is the difference between left outer join and (+) outer join? When I use left outer join the cost of the SQL
query is high, and when I use the (+) operator the join cost is much less.
There are three types of outer joins, left, right and full. A left outer join contains all records of the "left" table even if it has no matches in the "right" table specified in the join. A right outer join contains all records in the "right" able even if it has no matches in the "left" table. A full outer join contains all records of both the left and right tables.
In ANSI SQL 92 syntax, you specify a left outer join with the LEFT OUTER JOIN operand in your SQL statement. So a left outer join in SQL 92 syntax might look like the following:
SELECT x.id, x.colZ, y.colA FROM x LEFT OUTER JOIN y ON x.id=y.id;
Before Oracle supported this syntax, you used the "(+)" operator to define an outer join. To perform the left outer join example above with the "(+)" operator, the SQL statement would look like:
SELECT x.id, x.colZ, y.colA FROM x, y WHERE x.id=y.id(+);
You can easily change the above to a right outer join by moving the outer join operator as follows:
SELECT x.id, x.colZ, y.colA FROM x, y WHERE x.id(+)=y.id;
You should not be experiencing performance differences with the differences in notating the left outer join, provided your query is written properly. Ensure you have the WHERE clause instead of the ON clause when using the older outer join notation. Otherwise, you might have to file a bug report with Oracle Support.
Dig deeper on Oracle and SQL
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.