Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

Query on Multi row fetch CPU time performance improvements

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DB2 SQL - DB2 PROGRAMMING
  View previous topic :: View next topic  
Author Message
MFdevlpr
Member


Joined: 11 Nov 2014
Posts: 2
Location: Bangalore

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Nov 11, 2014 2:42 pm    Post subject: Query on Multi row fetch CPU time performance improvements Reply with quote

Hi,

I had done a bit of research on Multi-row fetching in COBOL-DB2 application programs for CPU time utilization/performance improvement and tried to implement the same in my system.

There is a COBOL-DB2 batch program which reads from DB2 tables and writes into a flat file as an extract of data.
The driving cursor has UNION ALL and its a join of 3 tables. I have verified the joins and the indexes defined, all look good.

In the peak time (something like during Christmas runs) the expectation is load would be more and the job might take too long to execute.

So, I tried Multi-row fetching (with row-set 100 once, with row-set 1000 once) to reduce the CPU time.

Below is the SQL query in cursor definition:

Code:
      SELECT A.Col1                     
            ,A.Col2                         
            ,A.Col3                         
            ,A.Col4                       
            ,B.Col5                     
            ,B.Col6                 
      FROM                                   
      (                                       
       SELECT C.Col1                   
             ,C.Col2                         
             ,C.Col3                         
             ,C.Col4                       
             ,MAX(C.SEQ_NO)   MAXSEQ         
       FROM                                   
      (                                       
       SELECT A.Col1                 
             ,A.Col2                       
             ,A.Col3                       
             ,A.Col4                     
             ,B.SEQ_NO                                 
        FROM  TableA A                               
             ,TableB B                               
             ,TableC C                               
        WHERE C.Col1 BETWEEN :WH-CR-PART-NO-FROM 
                         AND :WH-CR-PART-NO-TO   
          AND  C.Col1      =  A.Col1     
          AND  C.Col2      =  A.Col2           
          AND  A.Col3     >=  C.Col3           
  AND A.Col3 <= SUBSTR(STRIP(C.Col3) || "9999",1,5)
          AND  A.Col7 <= :WW-PROCESS-DATE     
          AND (A.Col8 >= :WW-PROCESS-DATE     
           OR  A.Col8 IS NULL)               
          AND  C.Col4         =  0                   
          AND  C.SEQ_NO          =  B.SEQ_NO         
          AND  B.Col9 <= :WW-WF-FORMAT-DATE   
          AND  B.ColA >= :WW-WF-FORMAT-DATE   
      UNION ALL                                           
       SELECT A.Col1                             
             ,A.Col2                                 
             ,A.Col3                                 
             ,A.Col4                               
             ,B.SEQ_NO                                 
        FROM  TableA A                               
             ,TableB B                               
             ,TableC C                               
       WHERE  C.Col1 BETWEEN :WH-CR-PART-NO-FROM
                         AND :WH-CR-PART-NO-TO   
         AND  C.Col1      =   A.Col1     
         AND  C.Col2      =   A.Col2         
         AND  A.Col7 <=  :WW-PROCESS-DATE   
         AND (A.Col8 >=  :WW-PROCESS-DATE   
              OR  A.Col8 IS NULL)           
         AND  C.Col4         =   A.Col4       
         AND  C.SEQ_NO       =   B.SEQ_NO         
         AND  B.Col9 <=  :WW-WF-FORMAT-DATE 
         AND  B.ColA >=  :WW-WF-FORMAT-DATE
        ) C                                             
              GROUP BY C.Col1                     
                      ,C.Col2                           
                      ,C.Col3                           
                      ,C.Col4 ) A                     
           ,TableB B                                   
            WHERE B.SEQ_NO = A.MAXSEQ                   
            ORDER BY Col1                         
                    ,Col2                               
                    ,Col4                             
        FOR FETCH ONLY                                   
      WITH UR                                           



I don't see any optimization after the multi-row fetch technique.

Code CPU # of Records Processed
Old 6.61 12068688
New 6.07 12068688

Its a mere 8% improvement on CPU time. As per some books, I read that it would be at least 60% of CPU time improvement.

I am afraid if I have missed anything in the process.
Can someone help me understand what could be the reason for not having much optimization for multi-row fetch technique.

Any help would be much appreciated.

Thanks in advance.
_________________
Vinay R
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

dbzTHEdinosauer
Moderator


Joined: 02 Oct 2006
Posts: 975

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Nov 17, 2014 7:32 pm    Post subject: Reply with quote

maybe because the multirow fetch only has affect on the result table,
which (by looking at the sql) is the resouce user and not the fetch.

i think that you will also find that the documentation concerning multirow fetch does little discussion of complex queries (in the sense of JOIN, UNION, subselects and host varibale usage).

have you tried running this trough an unload utility instead of a COBOL DB2 program and then parse the flat file with the host variables?

My experience with unload utilities is that the dump is so quick, that I can use a second step (COBOL or SORT) to parse the flat file and generate the desired output.
_________________
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
MFdevlpr
Member


Joined: 11 Nov 2014
Posts: 2
Location: Bangalore

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Nov 19, 2014 9:52 am    Post subject: Reply with quote

Hi Dick,

Thanks a lot for your reply.

As this query was a bit complex, I was trying out to improve performance without going to Sort.

The JCL with unload was already built and it was giving a better CPU performance.

To retain the readability and in the perspective of future maintenance, I had attempted to improve performance with multi-row fetch.

Seems like it won't help as much as the Unload dump and sorting does.

Thanks again for your time.

With regards,
Vinay R Laughing
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DB2 SQL - DB2 PROGRAMMING All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
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

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Query For IEBPTPCH 3 padmajeet.gaikwad 13445 Mon Feb 01, 2016 10:56 pm
academyindia4 View latest post
No new posts Unable to achieve below scenario using ICETOOL 27 sirianangel 33683 Mon Feb 01, 2016 10:01 pm
academyindia4 View latest post
No new posts Need to put records a Sorting order as mentioned below. 14 Yash1911 12634 Mon Jan 25, 2016 9:50 pm
academyindia4 View latest post
No new posts how to deal with the below scenario using iebgener 7 mainframes_6002 11170 Wed Dec 07, 2011 10:34 am
DikDude View latest post
No new posts Coulu someone explain the parameters in the below code? 1 lovely sweety 11352 Thu Jun 09, 2011 3:50 pm
dbzTHEdinosauer View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-7767.html