Solved

Knowledge on Nested loops , Hash joins and Merge joins

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

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 34

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.

Join & Write a Comment

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now