This article presents and tries to explain joins between two tables that can be encountered in Oracle: HASH, NESTED, MERGE
HASH join
Hash join operation consists of two steps in following order:
-
reads <outer table> and builds hash table in memory (PGA area, temp in case it’s big)
-
reads data from <inner table> and finds matching records in hashed <outer table>
----------------------------------------------
| Id | Operation | Name
----------------------------------------------
| 0 | SELECT STATEMENT |
| 1 | HASH JOIN |
| 2 | TABLE ACCESS FULL| <outer table> <- hash table in memory
| 3 | TABLE ACCESS FULL| <inner table>
-----------------------------------------------
This kind of join is the most popular in warehouses and enables to join very effectively large tables, sets of rows. <inner table> is quite often called “driving table” – table which searches data in other table. <outer table> which is hashed in memory you can treat as MEMORY INDEX.
Continue reading →