When HASH JOIN Is Healthy
Ideal for joining large row sets with equi-join predicates (=) where random index lookups would be slower than sequential scans.
When HASH JOIN Becomes a Production Bottleneck
Degrades when the build input is misestimated (building the hash table on the huge table instead of the small one) or when PGA overflows into TEMP (Used-Tmp > 0, multipass 0/1/M).
DBMS_XPLAN Tuning Checklist
- Confirm the first child (build table) has fewer A-Rows than the second child (probe table).
- Check OMem, 1Mem, and Used-Tmp columns for one-pass or multipass TEMP disk spills.
- Reduce selected column width before the hash join (avoid SELECT *) to keep the build table inside PGA.
Before (Slow Pattern)
SELECT * FROM fact_orders f JOIN dim_accounts a ON f.account_id = a.id;
After (Tuned Pattern)
-- Project only needed columns so PGA hash build table stays small SELECT f.order_id, f.total_eur, a.segment FROM fact_orders f JOIN dim_accounts a ON f.account_id = a.id;