Understanding Join Types in Oracle Execution Plans
1. Introduction
In Oracle Database, a SQL join written in a query (INNER JOIN, LEFT OUTER JOIN, etc.) does not directly map to what you see in the execution plan. Instead, the Cost-Based Optimizer (CBO) transforms logical joins into physical join operations based on statistics, indexes, data volume, and available access paths.
Understanding join types in execution plans is critical for:
2. Logical Joins vs Physical Joins
Logical Joins (SQL Level)
These are what developers write:
Physical Joins (Execution Plan Level)
These are how Oracle actually executes joins:
Execution plans always show physical join methods, not logical join syntax.
3. Nested Loops Join
NESTED LOOPS
How It Works
Pseudo logic:
FOR each row in outer_table
FIND matching rows in inner_table
When Oracle Chooses It
Example Plan
NESTED LOOPS
TABLE ACCESS BY INDEX ROWID EMP
INDEX RANGE SCAN EMP_DEPT_IDX
Performance Notes
4. Hash Join
Execution Plan Name
HASH JOIN
How It Works
Pseudo logic:
BUILD hash_table FROM smaller_table
FOR each row in larger_table
PROBE hash_table
When Oracle Chooses It
Example Plan
HASH JOIN
TABLE ACCESS FULL DEPARTMENTS
TABLE ACCESS FULL EMPLOYEES
Performance Notes
5. Merge Join
Execution Plan Name
MERGE JOIN
How It Works
Pseudo logic:
Recommended by LinkedIn
SORT table1 ON join_key
SORT table2 ON join_key
MERGE results
When Oracle Chooses It
MERGE JOIN
SORT JOIN
TABLE ACCESS FULL EMP
SORT JOIN
TABLE ACCESS FULL DEPT
Performance Notes
6. Cartesian Join
Execution Plan Name
MERGE JOIN CARTESIAN
How It Works
rows(A) × rows(B)
When It Occurs
Example Plan
MERGE JOIN CARTESIAN
TABLE ACCESS FULL A
TABLE ACCESS FULL B
Performance Notes
7. Outer Join Variants in Execution Plans
Oracle does not display OUTER JOIN directly. Instead, it shows join methods with the word OUTER.
Common Forms
HASH JOIN OUTER
MERGE JOIN OUTER
NESTED LOOPS OUTER
Meaning
8. Join Direction and Driving Table
Execution plans are read top-down, inside-out.
Key points:
Use:
9. Adaptive and Hybrid Join Behavior
In modern Oracle versions (12c+):
HASH JOIN (ADAPTIVE)
Oracle may start with one join method and switch if row counts differ from estimates.
10. Summary Table
11. Conclusion
Oracle execution plans reveal how joins are physically executed, not how they are written. Understanding join types such as Nested Loops, Hash Join, and Merge Join allows database professionals to:
Mastering execution-plan join analysis is a core skill for any Oracle DBA or SQL performance engineer.
Good One !!
Good consolidation... Thanks for sharing
Good one!!
Dear Rajkumar, Thank You so much for Your this Best Summarize,Consolidated and Clarify based on Sharing,it's really helpful and insightful for all of us,