Solved

Knowledge on Nested loops , Hash joins and Merge joins

Posted on 2014-09-12
4
213 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
4 Comments
 
LVL 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 recover a database from a user managed backup

860 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