473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

merge performance

AIX 5.1, DB2 8.1.3 64-bit ESE 5 partitions 1 catalog, 4 data.

I have a situation where I have to update 269,000,000 rows in a table
with the value in another table with just about the same number of
records. It's a reporting table and the update is based on the
primary key and both tables are indexed to support to the look up.
Both tables also share the same partitioning key and are in the same
node group.

My first try was to declare a cursor to select the fields I need from
the base table, then loop though the cursor and update the records.
The performance was almost exactly 1000 rows per minute, so it was
going to take about 186 days to finish. Not good.

So since it's a partitioned database, I thought I'll connect to one
partition (export DB2NODE=X) and then change my cursor and update to
include where the dbpartitionnum(part key) = current dbpartitionnum.
Performance was the same. Still not good.

So then I wrote a corollatted update like
update report_table A set A.col = (select B.col from base_table B
where A.key = B.key) where exists (select * from base_table B where
A.key = B.key)
Performance still stunk.

So, then I though let me try a merge statement like
merge report table as rpt ( select key + one column to update from
base table ) base
on key when matched update rpt = base

All of sudden the post join performance of the update is 1,000,000
rows a minute and I'm going to finish in about 5 hours. What gives?
Can someone please explain to me what the merge is doing under the
covers that works so well?

Thanks!
Nov 12 '05 #1
2 3805
Interesting.
The answer will lie in the plans.
1) W.r.t. the concurrent cursor
Does the plan show colocation?
Could it be the source was coming from one partition only, limiting
the paralleism you could get out of it.
2) Update.
You state you the join was on a key column.
DB2 should have rewritten the query to a simple join, updating the
target leg. It shouldn't have been slower than the merge after that
rewrite. need to see the plan.
3) Merge
I'm impressed, given that you are on FP3.
You should see further improvement whenyou go to FP5 or even better
FP6. FP3 isn't exploiting have the tricks possible.

Cheere
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
One more thought about MERGE vs. UPDATE.
In UPDATE the target will be the outer of the join
In MERGE the target will be the inner of the outer join

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kevin King | last post by:
I have a question about an assignment I have. I need to count the number of comparisons in my merge sort. I know that the function is roughly nlog(n), but I am definately coming up with too many...
9
by: DraguVaso | last post by:
Hi, I have two DataTables (our DataViews or whatever that will suit the best for the solution). I want to merge these two DataTables the fastest as possible, but they have to be merged one table...
3
by: Bob Stearns | last post by:
We have a very poorly performing MERGE statement (an hour or more on tables of ~10000 and ~100000). This may require building temporary tables with appropriate indexes, but I thought I would ask...
16
by: UDBDBA | last post by:
Hi All: I need some clarification on a MERGE statement. The database is on V8 FP12 (AIX) 64bit. The source table is tableA. The target is a View "FACT" with UNION ALL because of the 512 Gig...
0
by: sk.rasheedfarhan | last post by:
Hi all, I set the configuration for Merge replication for Subscription on one database and I have created the Merge replication for publication on another machine. And I updated columns of...
2
by: eavery | last post by:
Does anyone know of any documentation on the performance of partition merge/split? Does the merge or split of a partition cause any locking on the partitioned table? If you were merging or...
0
by: eavery | last post by:
Does anyone know of any documentation on the performance of partition merge/split? Does the merge or split of a partition cause any locking on the partitioned table? If you were merging or...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
24
by: Henry J. | last post by:
My app needs to insert thousand value rows into a mostly empty table (data are read from a file). I can either use inserts, or use merge. The advantage of using merge is that in the few cases...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.