Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Aug 27, 2007 1:50 pm Post subject:
rameshb,
We need more information on the indexes to be able to help you. Also post your sql so that it is readable and easily understandable
ex : like
Code:
SELECT I_REQ_SRV
,I_TYP_REQ_SRV
,T_CTE_TRG
,T008.I_RSN
,T004.I_STA
,I_PRI
,I_TO_ASN
,I_LCK
,T004.I_DOM_UDT_RCD
,T004.I_UDT_RCD
,T004.T_UDT_RCD
,I_DOM_UDT_LST_IFO
,I_UDT_LST_IFO
,T_UDT_LST_IFO
,T004.T_CRT_RCD
FROM VCCM904A_STA_DSC T904
,VCCM004A_SRV_REQ T004
,VCCM008A_RSN_ASN T008
,VCCM909A_RSN T909
WHERE T004.I_STA = T904 . I_STA
AND T904.N_STA IN ( 'Open', 'Pending' )
AND I_TO_ASN = :H : H
AND (:H :H IS NULL OR T_CTE_TRG < : H : H )
AND C_ASN = 1
AND T008.C_TYP_OWR = 'SERVICEREQUEST'
AND T004.I_REQ_SRV = T008.I_OWR
AND T008.I_RSN = T909.I_RSN
AND T909.I_CAT_RSN = 1
Quote:
AND (:H :H IS NULL OR T_CTE_TRG < : H : H )
what exactly you want to check with that statement?
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
Posted: Mon Aug 27, 2007 1:57 pm Post subject:
To add to Kolusu's list of 'what in the world is this?', what do you mean by
Quote:
AND I_TO_ASN = :H : H
You can NOT set a host variable to NULL as in
Quote:
AND (:H :H IS NULL OR T_CTE_TRG < : H : H )
and attempt to use it in a predicate.
Binary zeroes in a host variable are not the same as a DB2 NULL.
nor does the usage of a host variable NULL indicator set to -1 = a DB2 NULL.
The NULL predicate is only valid against a COLUMN.
Have you run EXPLAIN?
Have you tried to execute this? or pre-compile or bind it?
What version of DB2 are you using? and on what platform?
anyway, those are my thoughts.
edited several times by dbz in an attempt to make it a positive post _________________ Dick Brenholtz
American living in Varel, Germany
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
Posted: Mon Aug 27, 2007 3:10 pm Post subject:
rameshb,
OK, it is a four table join. You need an EXPLAIN.
The construct of the 4 tables and relationships between the 4 tables is only something that you know. You are the only one that knows what indexes exist.
Indexes, size of tables, the join types - only an EXPLAIN can tell you that.
Is Visual Explain available on your DB2 release? (which version of db2 are you on?).
There are all kinds of things that can be done, maybe. It depends.
Is this SQL imbedded in an application or is it a Stored Procedure?
Is this for online or batch?
How often is it executed?
How long is it taking now? (yeah, I know, too long....)
How big is the box - what type - what OS - what else is running in the DB2 space?
try to answer a few of these questions. Important questions to answer are:
Online or batch
Imbedded or Stored Procedure
Frequency
Info on your box (computer).
VSN of DB2!!!!!!!!!!
I am not avoiding your question. I (nor anyone else) have any idea where to start with suggestions.
Need more info!!! _________________ Dick Brenholtz
American living in Varel, Germany
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
Posted: Mon Aug 27, 2007 11:57 pm Post subject:
rameshb,
Though the following may sound like nagging, lack of information prohibits any type of productive suggestions. Like coding in COBOL, a good habit is to 'Fully qualify all references'. The four way implicit JOIN could possibly be optimized with different JOIN syntax or sub-selects. But, we have no idea which table contains these columns:
and in the where clause, the following is impossible to attempt to optimize:
C_ASN
I_TO_ASN
V_I_TO_ASN
So, full column qualification along with answers to the following will help us in providing some productive suggestions:
1. Are all four of these tables temporary?
2. what is the expected row count of each table?
3. What SQL was used to populate the temporary table(s)?
4. Are all predicate columns of the same datatype?
I realize that this seems like a great volume of info to provide, but there is more. You mentioned inserting?
Also, a general flow of the Stored Procedure would help. Does not make sense to optimize only part of the SP.
What language is the SP? is this SPL?
Good morning, by the way. _________________ Dick Brenholtz
American living in Varel, Germany
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum