Posted: Wed Jul 05, 2006 4:44 am Post subject: Effect on CPU time - DB2 prog with cursor
Hi,
I have a program that selects daily data from a DB2 table using Cursor and formats some fields of data and writes them to an O/P file. In other words it extracts the data from DB to file. Daily data can go upto 32K.
CPU time for it's execution is 2 min 27 sec. What can be the reason for the CPU time to go in min? Is it because of the cursor?
Is there any other way so that i can reduce the CPU time for this Job.
In your case you need to check if your Cursor is using an index or not. Also another alternative is to use DSNTIAUL to unload and reformat the output to your needs.
In your case you need to check if your Cursor is using an index or not.
Cursor is using indexes in Where and order by clause, only two extra fields are present in where clause that not part of indexes.
Quote:
Also another alternative is to use DSNTIAUL to unload and reformat the output to your needs.
I tried both logics in test region to see the diff. For 180 records in DB (test region) these are some the statistics.
1) Actual cursor program.
It took 00.63 sec of CPU.
2) Another job with one step for DB extract using DSNTIAUL and second step for executing program with that extract file as input and formatting and creating o/p file.
step1 to extract took 00.12 sec
step2 for executing prog to format data: 00.61 sec.
But even this breaking of logic is somehow again increasing the time of job.
I was going through the link that you provided. According to that info during file processing program issues EXCP calls and is eligible to be "swapped out" or "put on hold".
So does it mean that increase in no. of files used in a program increases it's chance of being swapped out? hence increase in processing time.
Since this happens during each record processing, increase in no of records of file may also increase it's chance of being swapped out.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Thu Jul 06, 2006 5:06 am Post subject:
Quote:
2) Another job with one step for DB extract using DSNTIAUL and second step for executing program with that extract file as input and formatting and creating o/p file.
step1 to extract took 00.12 sec
step2 for executing prog to format data: 00.61 sec.
Deepatred,
In which language is the Pgm to reformat the data coded? Can you explain the rules of reformating? If so may be I can suggest something.
Thanks for the reply.
Actually i am somewhat new to mainframe and DB2, so not familiar to all those terms.
Could you please let me know some more details. Where to find those info and how these things affect
the performance of query.
Joined: 10 Oct 2003 Posts: 315 Topics: 49 Location: Germany
Posted: Fri Jul 07, 2006 1:11 am Post subject:
deepatred,
the topic "how to use DB2 explain command" was dicussed several times in this forum. Pls use the search function to find the link.
But in general the influence on performance regarding the index structure, type on index, cluster / non cluster index, valid static data ..... require some skill and experience. So if you are not familiar with some general concepts the results of the DB2 explain Command wounn't help you. Because of the explain command (and in addition catlog information) will only tell you what for example "an cluster index with matchcolumns 2 is used".
So my proposel for the future: Look for an training / basic information about the general concepts of DB2 (and other database systems.......). Well it's hard, but witthout knowing your select statement, the databasestructure and the statistic data nowbody will be able to find out wether your select is the problem or the bad performance has any other reasons.
The background of my post was only, to give some ideas, not to explain general database concepts and the implementaion in ibms db2.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Fri Jul 07, 2006 7:27 am Post subject:
deepatred,
I don't think you really need a cobol program for formatting the output. you can use an utility to format the input or even the unload utility can do that itself. Post your cobol layout of the table and also specify the fields that need to have the sign reverted and split fields. A sample input and desired output also would help.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Tue Jul 11, 2006 7:59 am Post subject:
Deepa,
If you don't have DFSORT then you may not be able to use IFTHEN and OVERLAY which would make job easier and all calculations can be done within a single step. With syncsort version you have you need two steps. try this job
Thanks a lot for this solution it's working out and taking only .10 sec also got to learn some new features of syncsort that i had not used till now.
But there is one problem that i could not figure out, file REST is not getting any record? Those non 'HH' and 'CC' records are not getting written in REST file and somehow getting discarded and thus the final output file is not getting those records.
Also why 5 digit SEQNUM is being generated in file 'HH'? As far as i can
see we are not using that anywhere.
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Fri Jul 14, 2006 4:15 am Post subject:
Quote:
But there is one problem that i could not figure out, file REST is not getting any record? Those non 'HH' and 'CC' records are not getting written in REST file and somehow getting discarded and thus the final output file is not getting those records
Are you sure you have the keyword SAVE on the OUTFIL of rest? If so all the non 'HH' and 'CC' WILL be copied to hat DD name.
Quote:
Also why 5 digit SEQNUM is being generated in file 'HH'? As far as i can
see we are not using that anywhere.
Isn't that one of your requirement , if the code is 'cc' then increment the counter?
OUTFIL FNAMES=RPT,
REMOVECC,NODETAIL,
TRAILER1=('TOTAL RECORDS PROCESSED : ',
TOT=(77,1,ZD,M11,LENGTH=8),/,
'TOTAL RECORDS OF RS01-CNOPR NOT = HH : ',
TOT=(78,1,ZD,M11,LENGTH=8),
80:X)
/*
//SYSERR DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*
Oh that was a working storage counter and used later to write count in the second file. But that is fine, i just thought if putting that seq no. had any other significance.
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