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
 
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: 965
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: 965
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: 965
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: 6968
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 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 CONTIG for performance? JPVRoff JCL & VSAM 8 Fri Jun 09, 2017 8:39 am
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