Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Pls suggest to optimize below query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Pls suggest to optimize below query.
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us