Solved

Knowledge on Nested loops , Hash joins and Merge joins

Posted on 2014-09-12
4
215 Views
Last Modified: 2014-09-16
Hi ,

I need to know the situations when oracle uses Nested Joins , Merge Joins and Hash Joins  and also is it possible to make oracle use hash join instead of an nested join.
0
Comment
Question by:sam_2012
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 167 total points
ID: 40319951
Can't answer the first part but the second part, you can tell Oracle to use a hash with the USE_HASH hint.

http://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm#SQLRF51108

Note:
That is only a 'hint'.  Oracle can still choose to not follow the hint.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 167 total points
ID: 40319970
actually  hints, despite their name, are directives.

however - the rules for when a hint will be illegal are not well documented,  so it might look like you're being ignored; but really you told the optimizer to do something it couldn't.


When oracle uses one method over the other is determined by the estimated cost of doing them (rbo only uses nested loops) .

If you're up to it, Jonathan Lewis' book Cost-Based Oracle Fundamentals digs into it with a LOT of depth.   Don't let the term "Fundamentals" confuse you.  It's not light reading of intro material.

It's "fundamentals" like quantum particles are "fundamental" to physics.
0
 
LVL 35

Assisted Solution

by:Mark Geerlings
Mark Geerlings earned 166 total points
ID: 40320152
All of these join options are good sometimes.  None of these are always bad.  It depends on the numbers of records involved in the tables, and it usually also depends on what bind variables are provided in the query, and on which columns are indexed.  It also depends a bit on your: server memory,  your SGA size and your other SGA settings.

Rather than focusing on a general discussion of the pros and cons of one of these options compared to another, it may be more helpful for you to focus on particular problem queries or programs *AFTER* you are confident that your Oracle init parameters are appropriate for your: server and storage hardware; your data base size, your application, your number of users, etc. and that your table statistics are up-to-date and getting recalculated at regular intervals.

If your init values are not optimum, or if your table statistics are not up-to-date, don't waste time trying to force one particular join option over another.
0
 

Author Comment

by:sam_2012
ID: 40326966
Thanks for all the suggestions. I have brought a copy of cost based optimiser fundamentals from Jonathan lewis , going thru it . Also , modified the join condition on the tables , now it is not using the nested loops but hash joins.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question