Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Could you please any tune the query to increase performance

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
natarajanibm
Warnings : 1

New User


Joined: 21 Mar 2009
Posts: 9
Location: chennai

PostPosted: Thu Oct 14, 2010 9:58 pm    Post subject: Could you please any tune the query to increase performance
Reply with quote

Code:
EXEC SQL DECLARE SUSPENSE CURSOR FOR                 
***UNRESERVED PAYMENTS ***                               
    SELECT A.TRTYP,                                   
           A.CLNTID,                                 
           A.CNNO,                                   
           A.TRANNO,                                 
           A.CRRSN,                                   
           A.ORICRAMT,                               
           A.LFTOVAMT,                               
           A.CREFDT,                                 
           DAYS(:LP-PROCESSING-DT) - DAYS(A.CREFDT), 
           "N",                                       
           C.CMPCODE                                 
      FROM VLP1013 A, VLP1082 B, VLP1011 C           
     WHERE A.LFTOVAMT > 0                             
       AND A.CASTATCD ¬= "XT"                               
       AND A.CREFDT   BETWEEN "1991-01-01"                 
                          AND :WS-NEXT-WORK-DT             
       AND A.TRANNO = B.TRANNO                             
       AND A.TRANNO   BETWEEN 0000000001 AND :WS-MAX-TRANNO
       AND B.ACCTPRDT BETWEEN "1991-01-01"                 
                          AND :LP-PROCESSING-DT             
       AND A.CLNTID = C.CLNTID                             
  UNION ALL                                                 
                                                           
      SELECT A.TRTYP,              THER UNRESERVED CREDITS ***                                                       
           A.CLNTID,                                       
           A.CNNO,                                         
           A.TRANNO,                                       
           A.CRRSN,                                         
           A.ORICRAMT,                                     
           A.LFTOVAMT,                                     
           A.CREFDT,                                       
           DAYS(:LP-PROCESSING-DT) - DAYS(A.CREFDT),     
           "N",                                           
           C.CMPCODE                                     
      FROM VLP1013 A, VLP1066 B, VLP1011 C               
      WHERE A.LFTOVAMT > 0                                 
          AND A.CASTATCD ¬= "XT"                             
          AND A.CREFDT   BETWEEN "1991-01-01" AND :WS-NEXT-RK-DT                         
          AND A.TRANNO = B.TRANNO                           
          AND A.TRANNO   BETWEEN 0000000001 AND :WS-MAX-TRANNO
          AND B.ACCTPRDT BETWEEN "1991-01-01" AND :LP-PROCESSING-DT                           
          AND A.CLNTID = C.CLNTID                       
  UNION ALL
    SELECT A.TRTYP,          *** RESERVED PAYMENTS FOR BILLED CHARGES  ***                                       
       A.CLNTID,                                       
       A.CNNO,                                         
       A.TRANNO,                                       
       A.CRRSN,                                       
       A.ORICRAMT,                                     
       SUM(D.DBAMT - D.DBAMTPND),                     
       A.CREFDT,                                       
       DAYS(:LP-PROCESSING-DT) - DAYS(A.CREFDT),       
       "Y",                                           
       E.CMPCODE                                       
  FROM VLP1013 A, VLP1122 B, VLP1148 C, VLP1019 D,     
       VLP1011 E                                       
  WHERE A.TRANNO = B.CRTRANNO                           
       AND B.DBTRANNO = D.TRANNO                           
       AND B.DBTRSQNO = D.DBTRSQNO                         
       AND B.DBTRANNO = C.TRANNO                           
       AND C.TRSTATCD NOT IN ("CM", "OK")                 
       AND A.CASTATCD ¬= "XT"                             
       AND A.CREFDT   BETWEEN "1991-01-01"  AND :WS-NEXT-WORK-DT
       AND A.TRANNO   BETWEEN 0000000001 AND :WS-MAX-TRANNO
       AND A.CLNTID = E.CLNTID                             
  GROUP BY A.TRTYP, A.CLNTID, A.CNNO, A.TRANNO, A.CRRSN,
       A.ORICRAMT, A.CREFDT, E.CMPCODE               
 UNION ALL
    SELECT A.TRTYP,        *** OTHER RESERVED CREDITS ***
                         

       A.CLNTID,                                 
       A.CNNO,                                   
       A.TRANNO,                                 
       A.CRRSN,                                 
       A.ORICRAMT,                               
       SUM(D.DBAMT - D.DBAMTPND),               
       A.CREFDT,                                 
       DAYS(:LP-PROCESSING-DT) - DAYS(A.CREFDT),
       "Y",                                     
       E.CMPCODE                                 
    FROM VLP1013 A, VLP1122 B, VLP1066 C, VLP1019 D,     
         VLP1011 E                                       
    WHERE A.TRANNO = B.CRTRANNO                           
        AND B.DBTRANNO = D.TRANNO                           
        AND B.DBTRSQNO = D.DBTRSQNO                         
        AND B.DBTRANNO = C.TRANNO                           
        AND C.TRSTATCD ¬= "CM"                             
        AND A.CASTATCD ¬= "XT"                             
        AND A.CREFDT   BETWEEN "1991-01-01" AND :WS-NEXT-WORK-DT             
        AND A.TRANNO   BETWEEN 0000000001 AND :WS-MAX-TRANNO
        AND A.CLNTID = E.CLNTID                             
    GROUP BY A.TRTYP, A.CLNTID, A.CNNO, A.TRANNO, A.CRRSN,
             A.ORICRAMT, A.CREFDT, E.CMPCODE             
 UNION ALL
     SELECT "PO"         *** PAYMENTS TO CNA
                               
      ,B.CLNTID                                     
      ,B.CNNO                                       
      ,A.ASSOCTXN                                   
      ,"  "                                         
      ,SUM(A.TXAMT)                                 
      ,SUM(A.TXAMT)                                 
      ,A.PROCDTE                                     
      ,DAYS(:LP-PROCESSING-DT) - DAYS(A.PROCDTE)     
      ,"N"                                           
      ,C.CMPCODE                                     
  FROM VLP1220 A, VLP1014 B, VLP1011 C               
      WHERE A.PROPNO = B.PROPNO               
        AND B.CLNTID = C.CLNTID               
        AND SENDIND = "Y"                     
        AND ((STATUS  = "WB" AND PROCDTE <= :LP-PROCESSING-DT)   
        OR  (STATUS ¬= "WB"  AND PROCDTE <= :LP-PROCESSING-DT AND ACCTPRDT > :LP-PROCESSING-DT))   
 GROUP BY C.CMPCODE, B.CLNTID, B.CNNO,
         A.ASSOCTXN, A.PROCDTE       
 ORDER BY 11

Code'd
Back to top
View user's profile Send private message

Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Thu Oct 14, 2010 10:02 pm    Post subject:
Reply with quote

Wow. Where should I send the invoice?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 14, 2010 11:51 pm    Post subject:
Reply with quote

Hello,

As Phil mentions - how much are you (your organization) willing to spend?

Suggest you run an explain for this and then talk with your dba.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Fri Oct 15, 2010 12:09 am    Post subject:
Reply with quote

Hey Dick - butt out - this is my client.

Now, where were we...?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 15, 2010 12:45 am    Post subject: Reply to: Could you please any tune the query to increase p
Reply with quote

Hi Phil,

I gave ya credit - trying to get the rate up for you icon_smile.gif

d
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Fri Oct 15, 2010 12:45 am    Post subject:
Reply with quote

OK - sorry - the usual commission agreement still in force?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 15, 2010 12:49 am    Post subject: Reply to: Could you please any tune the query to increase p
Reply with quote

You get paid first - then we'll consider a commission. . .

Maybe we'll hear back from TS with some additional info as well. . .

d
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Oct 15, 2010 12:59 am    Post subject:
Reply with quote

probably along the lines of another question:

what is an explain and how do i do it?

or the one that I really love:

we are not allowed to run explain
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts BC, BCR, BRC, BRCL performance steve-myers PL/I & Assembler 0 Fri Dec 23, 2016 7:44 am
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us