473,396 Members | 2,029 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,396 software developers and data experts.

Co-releated Update Statement Tuning

A simple update involving two small tables takes 45 minutes to
complete. I would appreciate if you can kindly help me to understand
the root cause of this slowness. Users would be happy if I can bring
the timing down to 5 minutes or less.

Environment:
DB2 V8.1 FP 12 / AIX 5.3
Both are non-partitioned tables..residing on a logically partitioned
database

Table1: STG.TB_FIN_BRANCH has 34,658 records
Table2: STG.TB_STATE has 108 records

Update SQL :

update stg.tb_fin_branch aa set (aa.branch_state) = ( select coalesce
state,' ') from stg.tb_fin_branch br left outer join stg.tb_state st
on r.branch_state = st.state where aa.branch_sk = br.branch_sk)

Both tables has matching indexes and are in good shape as per runstat/
reorgchk statistics

Quote:
Table DDL:
$ db2 describe table STG.TB_FIN_BRANCH

Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ --------
----- ------
BRANCH_SK SYSIBM DECIMAL 10 0 No
BRANCH SYSIBM VARCHAR 6 0 No
BRANCH_ADDRESS SYSIBM VARCHAR 30 0 Yes
BRANCH_CITY SYSIBM VARCHAR 25 0 Yes
BRANCH_STATE SYSIBM VARCHAR 2 0 Yes
BRANCH_ZIPCODE SYSIBM VARCHAR 9 0 Yes
BRANCH_COUNTRY SYSIBM VARCHAR 2 0 Yes
CLOSED_DATE SYSIBM TIMESTAMP 10 0 Yes
CONTACT_SK SYSIBM DECIMAL 10 0 No
CONTACT_AGENCY SYSIBM VARCHAR 35 0 Yes

10 record(s) selected.

$ db2 describe indexes for table STG.TB_FIN_BRANCH show detail

Index Index Unique Number of
schema name rule columns Column names
------------------------------- ------------------ --------------
--------------
------------------------------------------------------------
STG WMX1 D 2 +BRANCH_STATE+BRANCH_SK
STG WMX2 D 10 +CONTACT_SK+CONTACT_AGENCY+CLOSED_DATE+BRANCH_ZIPC ODE
+BRANCH_CITY+BRANCH_ADDRESS+BRANCH+BRANCH_SK+BR ANCH_COUNTRY
+BRANCH_STATE

Table 2 DDL:
$ db2 describe table STG.TB_STATE

Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ --------
----- ------
COUNTRY SYSIBM VARCHAR 2 0 No
STATE SYSIBM VARCHAR 2 0 No
STATE_NAME SYSIBM VARCHAR 100 0 No
CTRY_STATE SYSIBM VARCHAR 100 0 No
STATE_ORDER SYSIBM DECIMAL 10 0 No

5 record(s) selected.

$ db2 describe indexes for table STG.TB_STATE show detail

Index Index Unique Number of
schema name rule columns Column names
------------------------------- ------------------ --------------
--------------
------------------------------------------------------------
STG IX1 D 1 +STATE

1 record(s) selected.

Explain Plan:
Access Plan:
-----------
Total Cost: 2.93797e+06
Query Degree: 1

Total Cost: 2.93797e+06
Query Degree: 1

Rows
RETURN
( 1)
Cost
I/O
|
34658
UPDATE
( 2)
2.93797e+06
69450.9
/----+----\
34658 34658
FETCH TABLE: STG
( 3) TB_FIN_BRANCH
2.07137e+06
34792.9
/----+----\
34658 34658
TBSCAN TABLE: STG
( 4) TB_FIN_BRANCH
1.20477e+06
134.857
|
34658
TEMP
( 5)
1.20473e+06
134.857
|
34658
NLJOIN
( 6)
1.20472e+06
134.857
/---+---\
34658 1
IXSCAN FILTER
( 7) ( 8)
446.489 456.5
66.8571 66.8571
| |
34658 34981.9
INDEX: STG HSJOIN
WMX1 ( 9)
450.066
66.8571
/-----+-----\
34658 108
IXSCAN IXSCAN
( 10) ( 11)
446.489 0.0933342
66.8571 0
| |
34658 108
INDEX: STG INDEX: STG
WMX1 IX1

Nov 5 '08 #1
3 2242
Sam Durai wrote:
A simple update involving two small tables takes 45 minutes to
complete. I would appreciate if you can kindly help me to understand
the root cause of this slowness. Users would be happy if I can bring
the timing down to 5 minutes or less.

Environment:
DB2 V8.1 FP 12 / AIX 5.3
Both are non-partitioned tables..residing on a logically partitioned
database

Table1: STG.TB_FIN_BRANCH has 34,658 records
Table2: STG.TB_STATE has 108 records

Update SQL :

update stg.tb_fin_branch aa set (aa.branch_state) = ( select coalesce
state,' ') from stg.tb_fin_branch br left outer join stg.tb_state st
on r.branch_state = st.state where aa.branch_sk = br.branch_sk)
Let be translate this into English:
You have a table TB_FIN_BRANCH with a column BRANCH_SK.
Now you want to fill in an extra (new?) column BRANCH_STATE for _all_
rows in the table based on TB_STATE.
I think you are doing an extra join here that isn't needed:

UPDATE stg.tb_fin_branch aa
SET aa.branch_state = COALESCE((SELECT state
FROM stg.tb_fin_branch AS br
WHERE aa.branch_sk = br.branch_sk),
' ');

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Nov 6 '08 #2
On Nov 6, 5:18*am, Serge Rielau <srie...@ca.ibm.comwrote:
Sam Durai wrote:
A simple update involving two small tables takes 45 minutes to
complete. I would appreciate if you can kindly help me to understand
the root cause of this slowness. Users would be happy if I can bring
the timing down to 5 minutes or less.
Environment:
DB2 V8.1 FP 12 / AIX 5.3
Both are non-partitioned tables..residing on a logically partitioned
database
Table1: STG.TB_FIN_BRANCH has 34,658 records
Table2: STG.TB_STATE has 108 records
Update SQL :
update stg.tb_fin_branch aa set (aa.branch_state) = ( select coalesce
state,' ') from stg.tb_fin_branch br left outer join stg.tb_state st
on r.branch_state = st.state where aa.branch_sk = br.branch_sk)

Let be translate this into English:
You have a table TB_FIN_BRANCH with a column BRANCH_SK.
Now you want to fill in an extra (new?) column BRANCH_STATE for _all_
rows in the table based on TB_STATE.
I think you are doing an extra join here that isn't needed:

UPDATE stg.tb_fin_branch aa
* * SET aa.branch_state = COALESCE((SELECT state
* * * * * * * * * * * * * * * * * * FROM stg.tb_fin_branch AS br
* * * * * * * * * * * * * * * * * * WHERE aa.branch_sk = br.branch_sk),
* * * * * * * * * * * * * * * * * *' ');

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab- Hide quoted text -

- Show quoted text -
try this -- it should run much faster.

Update Stg.Tb_Fin_Branch Aa
Set Aa.Branch_State =
(Select Coalesce(State,' ')
From Stg.Tb_State St Where Aa.Branch_Sk = Br.Branch_Sk)
Where Aa.Branch_State !=
(Select Coalesce(State,' ')
From Stg.Tb_State St Where Aa.Branch_Sk = Br.Branch_Sk)
Nov 6 '08 #3
On Nov 6, 1:18*pm, jmu...@chefscatalog.com wrote:
On Nov 6, 5:18*am, Serge Rielau <srie...@ca.ibm.comwrote:


Sam Durai wrote:
A simple update involving two small tables takes 45 minutes to
complete. I would appreciate if you can kindly help me to understand
the root cause of this slowness. Users would be happy if I can bring
the timing down to 5 minutes or less.
Environment:
DB2 V8.1 FP 12 / AIX 5.3
Both are non-partitioned tables..residing on a logically partitioned
database
Table1: STG.TB_FIN_BRANCH has 34,658 records
Table2: STG.TB_STATE has 108 records
Update SQL :
update stg.tb_fin_branch aa set (aa.branch_state) = ( select coalesce
state,' ') from stg.tb_fin_branch br left outer join stg.tb_state st
on r.branch_state = st.state where aa.branch_sk = br.branch_sk)
Let be translate this into English:
You have a table TB_FIN_BRANCH with a column BRANCH_SK.
Now you want to fill in an extra (new?) column BRANCH_STATE for _all_
rows in the table based on TB_STATE.
I think you are doing an extra join here that isn't needed:
UPDATE stg.tb_fin_branch aa
* * SET aa.branch_state = COALESCE((SELECT state
* * * * * * * * * * * * * * * * * *FROM stg.tb_fin_branch AS br
* * * * * * * * * * * * * * * * * *WHERE aa.branch_sk = br.branch_sk),
* * * * * * * * * * * * * * * * * *' ');
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab- Hide quoted text -
- Show quoted text -

try this -- it should run much faster.

Update Stg.Tb_Fin_Branch Aa
Set Aa.Branch_State =
* * * * (Select Coalesce(State,' ')
* * * * From Stg.Tb_State St Where Aa.Branch_Sk = Br.Branch_Sk)
Where Aa.Branch_State !=
* * * * (Select Coalesce(State,' ')
* * * * From Stg.Tb_State St Where Aa.Branch_Sk = Br.Branch_Sk)- Hide quoted text -

- Show quoted text -
correction

Update Stg.Tb_Fin_Branch Aa
Set Aa.Branch_State =
(Select Coalesce(State,' ')
From Stg.Tb_State St Where Aa.Branch_Sk = St.Branch_Sk)
Where Aa.Branch_State !=
(Select Coalesce(State,' ')
From Stg.Tb_State St Where Aa.Branch_Sk = St.Branch_Sk)
Nov 6 '08 #4

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

Similar topics

8
by: Malcolm Clift | last post by:
Hi All, Using wx, I'm trying to draw all items in a range of 50 in a text at certain co -ordinates (a simply textwrap) . A while back Alex Martelli was kind enough to give me the following to...
0
by: melledge | last post by:
Mozilla Foundation Co-Hosts Europe's Leading XML and Web Developer Conference XTech 2005 Conference to Bring Together XML and Web Technology Thought Leaders
1
by: Lee J. Moore | last post by:
I've spent a day writing software that will generate a multi-page/level family tree from a single HTML template and a Gedcom file, yet what seems like a minor issue with the CSS in the template is...
1
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed...
2
by: Mike | last post by:
I am using a server-side component for resizing/cropping images. Cropping is possible if I know the co-ordinates. I want to be able to offer users the ability to specify their own co-ordinates. ...
5
by: dm3281 | last post by:
Hi all -- We currently have an ecommerce application installed on a W2K Advanced server running .NET 1.1. In November, I installed .NET 2.0 in order to allow a Windows Forms application I...
8
by: john | last post by:
To test a new piece of software designed to help with (among other things) eCommerce WWW site development. The software is fairly easy to use but you must fit a profile. Retail price is 120 GBP and...
1
by: kailashchandra | last post by:
Hello Everybody i am trying to get co-ordinate position of mouse using java script using the following code.it works fine on IE and other but it is not working on mozilla.i couldn't...
1
by: =?Utf-8?B?QWJoaXNoZWsgUmFp?= | last post by:
Hi, I am working on the application which is based on the co-ordinate system it will support on different language(Globalization). My problem is to how can get relative co-ordinate in different...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.