Home » RDBMS Server » Performance Tuning » hash join vs nested loops (11g)
hash join vs nested loops [message #450475] Wed, 07 April 2010 09:04 Go to next message
orafacjublu
Messages: 95
Registered: May 2006
Location: KOLKATA
Member
Is it a pattern that 11g prefers nested loops over hash joins for the same query in 9i
Re: hash join vs nested loops [message #450480 is a reply to message #450475] Wed, 07 April 2010 09:14 Go to previous messageGo to next message
cookiemonster
Messages: 13922
Registered: September 2008
Location: Rainy Manchester
Senior Member
Doubt it. Have you got a specific example?
Re: hash join vs nested loops [message #450485 is a reply to message #450475] Wed, 07 April 2010 09:20 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Is it a pattern that 11g prefers nested loops over hash joins for the same query in 9i
The CBO in V11 is much, much, much smarter than CBO in V9.
Do you think you are smarter than V11 CBO & know how to make better choice than V11 CBO?
Re: hash join vs nested loops [message #450633 is a reply to message #450485] Thu, 08 April 2010 08:02 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Hash joins are preferred when joining large proportions (say, >10%) of a large table.

Indexed Nested Loops joins are preferred when joining small proportions (say, <1%) of a large table.

In the middle-ground, there are many factors that may make one more preferable to the other, such as the size of the Buffer Cache, memory available for hash joins, amount of disk cache, and probably tons of other stuff.

Oracle's optimizer will take many of these factors into account. Unless all factors are identical in two databases, you cannot expect the same result, even if they are the same version.

Also, 11g collects statistics on data automatically, and it probably gathers statistics of a different quality to those you gathered manually in 9i, leading to better optimizer decisions.

Even if all factors are equal, 11g optimiser will still have different / improved algorithms that will lead to different plans. It is possible that on average these changes favour Nested Loops, but it is MUCH MORE LIKELY to be one of those other factors if you are noticing a trend.

Ross Leishman
Previous Topic: Using SQL Tuning Advisor Interactively on already running task/job/batch
Next Topic: awr snapshots
Goto Forum:
  


Current Time: Sun May 12 21:09:24 CDT 2024