Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redundant hash join in SQL developer's autotrace execution plan?

Total newbie in SQL developer, I'm using the autotrace to understand the execution plan. In this autotrace output, what's the purpose of the last hash join?

autotrace output

Suppose the second ("the upper one") nested loop join can already be the final view as all the attributes are there and predicate conditions are met?

SQL:

SELECT TITLE, LASTNAME 
FROM MOVIE2 M, ARTIST A 
WHERE CODECOUNTRY='aaej' AND M.IDMES=A.IDARTIST;
like image 485
user7131669 Avatar asked May 29 '26 22:05

user7131669


1 Answers

Please check the new feature of Oracle 12g Adaptive Joins

e.g. here (blog) or here (white paper) or here (documentation)

Oracle will perform either NESTED LOOPS if there are small number of rows to be joined,

or will fall back to a HASH JOIN if there are a large number of rows, because the NESTED LOOP will take too long time to finish in this case.

The important line in the plan is STATISTICS COLLECTOR that observes the threshold of the row count and triggers the plan change if appropriate.

like image 113
Marmite Bomber Avatar answered Jun 01 '26 16:06

Marmite Bomber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!