IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Pls suggest to optimize below query.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
apandey

New User


Joined: 31 Aug 2009
Posts: 73
Location: Mumbai

PostPosted: Fri May 06, 2011 3:34 pm
Reply with quote

Hi All,

Below query is taking lots of time because of which the job is abending, giving time out reason. Pls Note: INDEX are already built on where clause predicates.

---------------------------------------------------------
EXEC SQL
DECLARE PVPWCUR CURSOR FOR
SELECT F1.I_MOD_YR
,F1.C_FAM
,F1.C_GRP
,Q1.I_VSC
,Q1.Q_PART_REQD
,Q1.Q_PART_FPV_ANNL
,X1.X_DESC
FROM
(SELECT DISTINCT(E1.I_PART)
,E1.I_MOD_YR
,E1.C_FAM
,E1.C_GRP
FROM E.EBUCREL E1
WHERE E1.C_STAGE_DVLP = '3'
AND E1.D_EFF_OUT = '9999-12-31'
AND E1.C_UM <> 'RF'
AND E1.I_MOD_YR = :EPVSDTL.I-MOD-YR
AND E1.C_FAM >= :WS-FAM-LOW
AND E1.C_FAM <= :WS-FAM-HIGH
AND E1.I_PART >= :WS-PART-LOW
AND E1.I_PART <= :WS-PART-HIGH
AND E1.C_GRP >= :WS-BCG-LOW
AND E1.C_GRP <= :WS-BCG-HIGH
) AS F1,

(
SELECT P1.I_MOD_YR
,P1.C_FAM
,P1.I_PART
,P1.I_VSC
,P1.Q_PART_REQD
,SUM(P1.Q_PART_FPV_ANNL) AS Q_PART_FPV_ANNL
FROM E.EPVSDTL P1
WHERE P1.I_PRTITN = :EPVSDTL.I-PRTITN
AND P1.I_MOD_YR = :EPVSDTL.I-MOD-YR
AND P1.C_FAM >= :WS-FAM-LOW
AND P1.C_FAM <= :WS-FAM-HIGH
AND P1.I_PART >= :WS-PART-LOW
AND P1.I_PART <= :WS-PART-HIGH
AND P1.I_VSC >= :MD-VSC-MIN
AND P1.I_VSC <= :MD-VSC-MAX
AND P1.C_LINE >= :MD-LINE-MIN
AND P1.C_LINE <= :MD-LINE-MAX
AND P1.C_MKT >= :MD-MKT-MIN
AND P1.C_MKT <= :MD-MKT-MAX
AND P1.I_PLT >= :MD-PLT-MIN
AND P1.I_PLT <= :MD-PLT-MAX
AND P1.C_SERIES >= :MD-SRS-MIN
AND P1.C_SERIES <= :MD-SRS-MAX
AND P1.C_BDY_STYLE >= :MD-BDYSTL-MIN
AND P1.C_BDY_STYLE <= :MD-BDYSTL-MAX

GROUP BY P1.I_MOD_YR
,P1.C_FAM
,P1.I_PART
,P1.I_VSC
,P1.Q_PART_REQD
) AS Q1, E.EBLDGRP X1
WHERE F1.I_PART = Q1.I_PART
AND F1.I_MOD_YR = Q1.I_MOD_YR
AND F1.C_FAM = Q1.C_FAM
AND X1.C_GRP = F1.C_GRP
ORDER BY F1.I_MOD_YR
,F1.C_FAM
,F1.C_GRP
,F1.I_PART
END-EXEC.
--------------------------------------------------------------------------
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri May 06, 2011 9:04 pm
Reply with quote

Do you really think this is enough info?
which indexes ? one with all the columns, or one for each column ? in which order are the columns in the index ?
Which of the 8 predicates is most likely to be filled in and which is most selective/restrictive ?
You should at least use between instead of >= and <=
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top