Solved

Knowledge on Nested loops , Hash joins and Merge joins

Posted on 2014-09-12
4
216 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

688 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