Welcome Guest ( Log In | Register )


 
 
 
 
 
 

 
Oracle performance tuning 

software
 
Oracle 

performance Tuning 10g reference poster
 
Oracle training in Linux 

commands
 
Oracle training 

Excel
 
Easy Oracle Jumpstart
 
Oracle training & performance tuning books
 
Burleson Consulting Remote DB Administration
 
 
> MERGE statement and APPEND hint
Starikovsky
post Nov 13 2007, 12:40 PM
Post #1


Advanced Member
***

Group: Members
Posts: 119
Joined: 13-November 07
Member No.: 13,939



From the functional point of view it is clear to me how the MERGE statement works.
It is also clear to me APPEND hint will allocate space beyond HWM each time an INSERT statement is issued.

> What I'm Wondering Is
How does MERGE statement works with an APPEND hint?

> Scenario
Assume a large partitioned table populated/updated from a staging area via MERGE statement.
MERGE statement will UPDATE when PK match and will INSERT when PK doesn't match.
Assuming insertable and updateable rows are scatered in staging area MERGE will issue either INSERT or UPDATE statements as needed.

> Question
If this is the case, it's safe to say MERGE/Insert will push HWM a little higher each time a new row is inserted? If it works this way process will be allocating a lot of space and leaving huge amounts of unused space under the HWM, is that correct?


Thank you in advance.
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
burleson
post Nov 14 2007, 09:24 AM
Post #2


Advanced Member
***

Group: Members
Posts: 7,973
Joined: 26-January 04
Member No.: 13



Hi,

> each time a new INSERT is issued by MERGE statement HWM would go a little higher.

No, only after the block is full . . . You could insert 100 rows in append mode before changing blocks.

The append hint does not mean one row per block!

The append hints says "When it's time to grab a new block, grab a fresh, empty one."

>> Does MERGE actually issues a mixed set of UPDATE and INSERT commands -as needed- against the target table?

Good question. Oracle does not disclose the internal machinations of the upsert. The docs are conflicting:

This suggests "yes":

http://www.oracle.com/technology/products/...comp_dwflow.pdf

The MERGE-statement combines the sequence of a conditional INSERT and UPDATE in one single atomic statement, Oracle9i overcomesthese deficiencies and makes the implementation of warehousing applications more simple and intuitive.The ‘IF ROW EXISTS -THEN-UPDATE ELSE-INSERT’ - conditional sequence is also referred to as UPSERT

This says "no", it's a single scan, optimized internal feature:

http://www.oracle.com/technology/products/...aily/Aug24.html

The new MERGE command overcomes these deficiencies, processing the conditional INSERT-or-UPDATE within a single statement. The data is scanned only once, and the appropriate DML command is issued, either serially or in parallel.

The new MERGE command brings major performance benefits by providing an optimized internal feature for the common Upsert task within ETL processing.

**********************************************************
As to merge performance, this article does a test and shows that a two-step is faster:

http://www.oracle-developer.net/display.php?id=203

We can see that MERGE performed less well than our two-part SQL solution; with it taking over twice as long.

David Aldridge has these notes, where he says to AVOID the merge for MV's and perhaps more:

http://oraclesponge.wordpress.com/2005/11/...esh-mechanisms/


--------------------
Hope this helps. . .

Donald K. Burleson
Oracle Press author
Author of Oracle Tuning: The Definitive Reference
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 8th September 2010 - 04:27 PM