Solved

Tuning Question

Posted on 2006-11-14
1
689 Views
Last Modified: 2008-02-01
select /*+ USE_MERGE(B,A) */ a.prod_id,
       a.prod_number,
       a.prod_name,
       a.update_date,
       b.term,
       b.term_type
  from merch a,
       term_details b
 where a.prod_id = b.prod_id

Experts,
  I just used TOAD to tune the following query and received this result as the best option. Before I use the code I wanted to understand what the solution was. I was hoping someone could explain the /* + USE_MERGE(B,A) */ comment? I don't want to use code and not fully understand what it's doing. Thanks!
0
Comment
Question by:ACSDBA
1 Comment
 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
ID: 17938715
Causes Oracle to join each specified table with another row source with a sort-merge join.

http://www.psoug.org/reference/hints.html

Merge join
Also called sort merge join. A merge join basically sorts all relevant rows in the first table by the join key , and also sorts the relevant rows in the second table by the join key, and then merges these sorted rows. Take an example! At a garage sale you can buy 400 books. The deal is to take all or none. You take all. Now, you have to find the books that you already have at home. How would you go about it? Probably, you'd do a merge join: first, you sort your books by the primary key (author, title), then you sort the 400 books by their primary key (auther, title). Now, you start at the top of both piles. If the value of the left piles primary key is higher, then you take a book from the right pile and vice versa. When both values are equal, then you have found a dublicate. To demonstrate a MERGE JOIN, two tables need to be created: The behaviour of merge joins is influenced by the initialization parameters sort_area_size and db_file_mutliblock_read_count.

http://www.adp-gmbh.ch/ora/sql/join/join_methods.html
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

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…
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…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

831 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