Is this possible to tune this query further :
Env : DB2 UDB 8.2 on AIX 5.3, Non partitioned tables
Query:
SELECT
ETL.T00601.*
FROM
ETL.T00601,
ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN
where
ETL.T00601.SVC_BUSNS_ASCT_CD =
ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN.BUSNS_ASCT_CD
AND
(
SUBSTR(VEH_IDENT_NBR,1,3) in ('9BG','8AG','6G1') AND
SUBSTR(VEH_IDENT_NBR,9,1) not in ('P','R','S','T','V') )
OR
(SUBSTR(VEH_IDENT_NBR,1,3) not in ('9BG','8AG','6G1') AND
SUBSTR(VEH_IDENT_NBR,10,1) in
('W','X','Y','1','2','3','4','5','6','7','8')
) "
I have the following indexes on these 2 tables
1) i4 ON ETL.T00601 ( VEH_IDENT_NBR ,SVC_BUSNS_ASCT_CD )
2) i2 ON ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN ( BUSNS_ASCT_CD )
After updating the system catalog statistics I found out that
CLUSTERRATIO is less that 60 for index i4 ( I tried to have index on
different columns but it didn't help to improve the CLUSTERRATION)
Access plan is generated as below
db2 set current explain mode explain
db2 explain all with snapshot for "SELECT ETL.T00601.* FROM
ETL.T00601,ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN where
ETL.T00601.SVC_BUSNS_ASCT_CD =
ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN.BUSNS_ASCT_CD AND (
SUBSTR(VEH_IDENT_NBR,1,3) in ('9BG','8AG','6G1') AND
SUBSTR(VEH_IDENT_NBR,9,1) not in ('P','R','S','T','V') ) OR
(SUBSTR(VEH_IDENT_NBR,1,3) not in ('9BG','8AG','6G1') AND
SUBSTR(VEH_IDENT_NBR,10,1) in
('W','X','Y','1','2','3','4','5','6','7','8')) "
db2exfmt -d card -g TIC -e card30 -f 0 -w -1 -1 -# 0 -o laam_expln4.out
Part of laam_expln4.out
Access Plan:
-----------
Total Cost: 1.04327e+06
Query Degree: 1
Rows
RETURN
( 1)
Cost
I/O
|
4.03973e+07
DTQ
( 2)
1.04327e+06
28958
|
4.03973e+07
NLJOIN
( 3)
1.02434e+06
28958
/-----+-----\
301024 134.2
TBSCAN IXSCAN
( 4) ( 5)
58885.7 106.036
28949 8
| |
3.0102e+06 1342
TABLE: ETL INDEX: CARD30
T00601 I2
Always ETL.T00601 goes for tablescan because of low CLUSTERRATIO( Am I
right ?? )
Any help is appreciated to improve this query performance. 9 2096
Guys, I'm sorry just now found out that this table is parititioned. So
this table T06001 is a partitioned table.
Try this. The idea is to have DB2 probe for the end result
after it knows the qualifying rows.
Now, there is a chance that DB2 outsmarts us and drops the new join.
SELECT
Y.*
FROM
(SELECT
ETL.T00601.SVC_BUSNS_ASCT_CD, ETL.T00601.VEH_IDENT_NBR
FROM
ETL.T00601,
ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN
where
ETL.T00601.SVC_BUSNS_ASCT_CD =
ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN.BUSNS_ASCT_CD
AND
(
SUBSTR(VEH_IDENT_NBR,1,3) in ('9BG','8AG','6G1') AND
SUBSTR(VEH_IDENT_NBR,9,1) not in ('P','R','S','T','V') )
OR
(SUBSTR(VEH_IDENT_NBR,1,3) not in ('9BG','8AG','6G1') AND
SUBSTR(VEH_IDENT_NBR,10,1) in
('W','X','Y','1','2','3','4','5','6','7','8')
)) AS X,
ETL.T00601 AS Y
WHERE X.SVC_BUSNS_ASCT_CD = Y.SVC_BUSNS_ASCT_CD
AND X.VEH_IDENT_NBR = Y.VEH_IDENT_NBR;
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thanks, Access plan shows less timerons now to run this query so I
believe that it would give a better performance. New access plan is
here
Access Plan:
-----------
Total Cost: 176642
Query Degree: 1
Rows
RETURN
( 1)
Cost
I/O
|
4.03979e+06
DTQ
( 2)
176642
37150.7
|
4.03979e+06
NLJOIN
( 3)
174749
37150.7
/-------+------\
30102.9 134.2
NLJOIN IXSCAN
( 4) ( 9)
78097.5 106.036
37141.7 8
/---+---\ |
301024 0.100001 1342
TBSCAN IXSCAN INDEX: CARD30
( 5) ( 8) I2
59319.9 25.7384
28949 2
| |
301024 3.0102e+06
I've a quick question. I have 3 million rows in ETL.T00601 table and
1500 rows in ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN table but when I
execute this query it I expected it to fetch less than 3 million rows
but it has fetched so far around 22 Million row which puzzles me. Any
idea?
db2udbgirl wrote: Thanks, Access plan shows less timerons now to run this query so I believe that it would give a better performance. New access plan is here Access Plan: ----------- Total Cost: 176642 Query Degree: 1
Rows RETURN ( 1) Cost I/O | 4.03979e+06 DTQ ( 2) 176642 37150.7 | 4.03979e+06 NLJOIN ( 3) 174749 37150.7 /-------+------\ 30102.9 134.2 NLJOIN IXSCAN ( 4) ( 9) 78097.5 106.036 37141.7 8 /---+---\ | 301024 0.100001 1342 TBSCAN IXSCAN INDEX: CARD30 ( 5) ( 8) I2 59319.9 25.7384 28949 2 | | 301024 3.0102e+06
I've a quick question. I have 3 million rows in ETL.T00601 table and 1500 rows in ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN table but when I execute this query it I expected it to fetch less than 3 million rows but it has fetched so far around 22 Million row which puzzles me. Any idea?
Hmm. This is not the plan I expected.
I was aiming for a NLJOIN between to covering indexes following by join
doing an ISCAN/FETCH
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
But still gives a better performance to me though :-)
Do you have any idea about my other question?
db2udbgirl wrote: But still gives a better performance to me though :-) Do you have any idea about my other question?
no clue
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
I was looking at your where clause, and I'm wondering if you add
another set of parenthesis' in there if it would clean up the results.
where
ETL.T00601.SVC_BUSNS_ASCT_CD =
ETL.STG_LAAM_CARD20_BUS_ASCT_BUS_FCN.BUSNS_ASCT_CD
AND
(
(
SUBSTR(VEH_IDENT_NBR,1,3) in ('9BG','8AG','6G1')
AND SUBSTR(VEH_IDENT_NBR,9,1) not in
('P','R','S','T','V')
)
OR
(
SUBSTR(VEH_IDENT_NBR,1,3) not in
('9BG','8AG','6G1')
AND SUBSTR(VEH_IDENT_NBR,10,1) in
('W','X','Y','1','2','3','4','5','6','7','8')
)
)
I'm curious what DB2 would do without these extra set of parens - I
would expect it to join the two tables AND do the first set of
filtering, and then discard that set of filters (for the OR clause) and
do the second set of filters. Which would result in a very very large
(and incorrect) result set. I'm not positive, though.
-Chris
ok No problem, That was due to a studpid mistake in my query. I have
resolved it. Thanks for your timely help.
Yes, I missed that extra set of paranthesis earlier as pointed by Chris. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian Oster |
last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a
query that used to execute in under 2 seconds, now takes over 8
Minutes to complete. Any ideas on what the heck might be going...
|
by: Paul Mateer |
last post by:
Hi,
I have been running some queries against a table in a my database and
have noted an odd (at least it seems odd to me) performance issue.
The table has approximately 5 million rows and...
|
by: Eugenio |
last post by:
Excuse me in advance fo my little English.
I've got this stored procedure
****************************************************************************
**********
declare @Azienda as...
|
by: Együd Csaba |
last post by:
Hi All,
how can I improve the query performance in the following situation:
I have a big (4.5+ million rows) table. One query takes approx. 9 sec to
finish resulting ~10000 rows. But if I run...
|
by: Rolan |
last post by:
There must be a way to enhance the performance of a query, or find a
plausible workaround, but I seem to be hitting a wall. I have tried a
few tweaks, however, there has been no improvement.
...
|
by: Tina |
last post by:
My employer tracks productivity/performance of clinicians (how much
they
bill) each week, its averages for the month, and the 6 months.
These averages are compared to their expected productivity....
|
by: rdemyan via AccessMonster.com |
last post by:
My application has a table that contains information on buildings. The
building data comes from another database and is imported from a spreadsheet
into my application.
Originally, I thought...
|
by: Brian Tabios |
last post by:
Hello Everyone,
I have a very complex performance issue with our production database.
Here's the scenario. We have a production webserver server and a
development web server. Both are running...
|
by: phlype.johnson |
last post by:
I'm struggling to find the best query from performance point of view
and readability for a normalized DB design.
To illustrate better my question on whether normalized designs lead to
more complex...
|
by: Jimbo |
last post by:
I have a query..if you look at the bottom of the where clause you'll
see an "NOT IN" statement that is really hanging up the query..i'm
trying to replace with a "NOT EXISTS" but it isnt appearing...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |