Home » RDBMS Server » Performance Tuning » MERGE INTO with a hint
MERGE INTO with a hint [message #162346] Thu, 09 March 2006 17:49 Go to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
I saw this SQL below in one of the topics posted. I just added a parallel hint:

merge /*+ parallel (emp,6) */ 
     into tabA a
    using ( SELECT c.prod_id,
                   c.as1,
                   c.val_amount 
              from tabB b,   
                   tabC c 
            where (b.date < sysdate
                   and b.b_no = c.c_no
                   and b.dimd = c.dimd
          )  YY 
    on (a.prod_id = YY.prod_id )
      when matched then 
        UPDATE set a.asl = YY.as1
                   a.aq1 = a.del * YY.val_amount;


I have a similar case, and just wondering if the hint applies to the SELECT or the UPDATE???


[Updated on: Thu, 09 March 2006 17:50]

Report message to a moderator

Re: MERGE INTO with a hint [message #162358 is a reply to message #162346] Thu, 09 March 2006 19:57 Go to previous messageGo to next message
rranjan1
Messages: 3
Registered: March 2006
Location: Singapore
Junior Member
The hint applies when you want to do both. i.e INSERT & UPDATE at the same time with one Query.

Let me know if above helps.
Re: MERGE INTO with a hint [message #162361 is a reply to message #162358] Thu, 09 March 2006 20:23 Go to previous messageGo to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
how about just UPDATE?? or just INSERT??
Re: MERGE INTO with a hint [message #162362 is a reply to message #162361] Thu, 09 March 2006 20:29 Go to previous messageGo to next message
rranjan1
Messages: 3
Registered: March 2006
Location: Singapore
Junior Member
Just INsert & Update do not require MERGE statement use.

ex: INSERT into table_name values (A,B,C)
select A,B,C from <condition>

-- Update based on condition. The condition should pass WHERE clause and then accordingly SET colm values. Here WHERE condition and select condition are same.
UPDATE table_name
set col_name = < select col_name from tablename where <condition>
where exists ( select col_name from tablename where <condition> )
Re: MERGE INTO with a hint [message #162383 is a reply to message #162362] Fri, 10 March 2006 00:19 Go to previous message
a_developer
Messages: 194
Registered: January 2006
Senior Member
I think the purpose of merge is to simply the combination of select and update at the same time. Can you please translate the MERGE statement above to a simple UPDATE statement whose cost will be less than when using MERGE??
Previous Topic: When to rebuild indexes ...
Next Topic: Problem with insert statements sharing in shared pool
Goto Forum:
  


Current Time: Fri Apr 19 16:44:19 CDT 2024