MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

performance of DB2 query vs Cobol table search

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
nishantrk
Beginner


Joined: 24 Mar 2006
Posts: 32
Topics: 16

PostPosted: Wed Apr 21, 2010 7:28 pm    Post subject: performance of DB2 query vs Cobol table search Reply with quote

I have to read a files which has around 10 million records.Then query a DB2 tableemployee category table to get his dept ,based on the indicator is get from the DB2 table do a write for the records.
Now the table has only 200 rows , does it make sense to have the DB2 table data loaded into a COBOL table ,then search the COBOL table .Instead of querying the DB2 table again and again?
Which methods is more efficient in general and is there any limitation on the how big the COBOL table is ,for it to be efficient ??
Back to top
View user's profile Send private message Send e-mail
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Apr 22, 2010 6:09 am    Post subject: Reply with quote

considering the 10 million 'look-ups' that you have to make,
which means 10 million suspensions of your program,
means that the cobol table look-up will finish
a day or two before the one with db2 for each record.
(the day difference is in jest!!)

there are no fast figures -

with only 200 rows, there is a good chance that db2
will have the complete table in memory
so, what we are avoiding is program suspension.
(as well as db2 code other than the actual code used for row acquisition).

a lot has to do with your site set-up. how big a machine you have,
how busy is it.

the larger the cobol table, the more working-storage you need,
the more resource you need to start your job.
if you exceed 4k, you may encounter paging.

I have had good results with 3,000 item internal cobol table and 1 million input records.

keep the item of your cobol internal table small,
the item fields the same datatype (PIC) as the file fields used in the comparison -
---convert as you load the table if necessary -
load from an ordered cursor -
make the table ODO -
use Binary Search -
and always check the last found against current file value before searching -
up the buffer count for the input and output files
(start with BUFNO=10 or 20 and experiment

I assume the program is batch and amode any, rmode 31.

any table properly designed will be efficient.
as to where is the cut-off point between when to load an internal cobol table
and when to do db2 access each time,
depends - and I am not going to suggest other than what I already have.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Thu Apr 22, 2010 3:34 pm    Post subject: Reply with quote

Whichever way you choose to implement, something that can save considerable time is checking if "this" record has the same dept as the previous lookup.

If the input is already in sequence by employee or dept/employee the number of lookups could nearly be eliminated completely. . .
_________________
All the best,

di


Last edited by papadi on Fri Apr 23, 2010 3:01 pm; edited 1 time in total
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Apr 22, 2010 5:16 pm    Post subject: Reply with quote

sorting the input file (10 million records) by dept no,
would potentially reduce the db2 selects by the number of dept_no not present in the file
and you would not need the cobol internal table.

but, how long does it take to sort 10 million records
once for this process
and then again for the next?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 22, 2010 5:54 pm    Post subject: Reply with quote

IMHO it is a good idea to load the table into internal table. Cobol has a limitation for internal tables of 16 MB which is a lot. Even in future if the table increases drastically you can still outperform 10 million SQL selects. The binary search is much more efficient/cheaper than a sql call.

Alternatively just dump the table into a flat file and load that it into an internal table there by eliminating the DB2 table access from the table.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nishantrk
Beginner


Joined: 24 Mar 2006
Posts: 32
Topics: 16

PostPosted: Thu Apr 22, 2010 6:42 pm    Post subject: Reply with quote

Thanks all for your views and suggestion...
Actually i had only mentioned part of code...the actual code does a lot more processing and has been optimized to do that..my requirement is just a small enhancement to that code...But since the code didn't have any SQL statements before this..wanted to add the solution that will have as little impacted on performance as possible..
So i guess as everyone suggested since its a small table..i will load it into a Cobol table and do a binary search...
Back to top
View user's profile Send private message Send e-mail
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Fri Apr 23, 2010 3:02 pm    Post subject: Reply with quote

Quote:
i will load it into a Cobol table and do a binary search...
But only if the dept of the current record is not the same as the dept of the previous record. . . Wink
_________________
All the best,

di
Back to top
View user's profile Send private message
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Tue Apr 27, 2010 1:50 pm    Post subject: Reply with quote

kolusu wrote:
...Cobol has a limitation for internal tables of 16 MB which is a lot...
Kolusu
128 MB minus 1 in the newer releases of COBOL.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Tue Apr 27, 2010 1:53 pm    Post subject: Reply with quote

Both Dick and papadi have pointed out a very important fact. Checking your current search argument against your previous can save a lot of time and many programmers overlook this.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database 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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group