Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Hash Joins vs. Nested Loops

Re: Hash Joins vs. Nested Loops

From: Alex Filonov <afilonov_at_yahoo.com>
Date: 25 Feb 2003 09:04:45 -0800
Message-ID: <336da121.0302250904.4b2cb3b6@posting.google.com>


rgaffuri_at_cox.net (Ryan Gaffuri) wrote in message news:<1efdad5b.0302201025.670fb5b8_at_posting.google.com>...
> Someone I was working with told me the following. I was wondering if
> anyone has any comments, because I have not seen this in any
> articles/books.
>
> He said that when he tunes he generally likes to try to force nested
> loop joins over hash joins because these tend to increase performance?
> He has done this for a long time and he said that is based on
> experience.
>
> Anyone else notice this? I have never seen this anywhere else. BTW, I
> know the difference between hash joins and nested loops and know when
> either is generally used by the optimizer.

The rule of thumb: If you need to filter tables before join, use hash or sort/merge. If not, use nested loops. Hash joins and sort/merge joins are very efficient when you join big tables, both in number of rows and columns and have some conditions restricting the number of rows/columns in the output. In case of hash or sort/merge, filtering is done before join. In case of nested loops, filtering is done after the loops. You can clearly see it in explained plans.

So, the correct answer is: Depends on your query. I had huge performance gains by forcing hash joins. I also had huge performance gains forcing nested loop instead of hash join. Received on Tue Feb 25 2003 - 11:04:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US