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
 

 

Compare one Million Records with 50 Records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vbhat

New User


Joined: 29 Apr 2005
Posts: 38

PostPosted: Mon May 23, 2005 3:46 pm    Post subject: Compare one Million Records with 50 Records
Reply with quote

1. I have two files. In one file there are millions of
records. and in the second file there are only 50
records. i want to compare these two files and if
matches i want to write in a third file. what is logic
in cobol. Only in cobol not in JCL.
Back to top
View user's profile Send private message

kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Mon May 23, 2005 5:28 pm    Post subject:
Reply with quote

you want to only those record which are present in both the file, then sort the first file, and take the sorted file as input to ur cobol program and perform binary search on the file which contains millions of record then to match the record present in the smaller file.
i m sujjesting binary search as it will be faster and more efficient in term of CPU ussage. Then when u find a record present in both the file write to ur output file.
if u take sorting as external one then i think it will be more better.
if you have any better idea, plz let me know.
Back to top
View user's profile Send private message
avalanches

New User


Joined: 10 May 2005
Posts: 28

PostPosted: Wed May 25, 2005 5:59 pm    Post subject: Re: I have two files. In one file there are millions of
Reply with quote

I'm not sure if the following the 'most' effective way. But, depends upon the records in the smaller file, it could be effective.

1. Sort mn rcds file & 50 rcds file in the same order.
2. From 50 rcds file get 1 rcd.
3. From mn rcds file get 1 rcd. Try finding out a match in mn rcds file. Upon finding one, write it out in the third file. If the mn rcds file is lesser, get next record from mns record file. If 50 rcds file record is lesser then do step 2 till all 50 records are exhausted OR mns records are exhausted.

Cheers,
avalanches.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon May 30, 2005 12:04 am    Post subject:
Reply with quote

If this is a ques resulting from a real life (business) problem, you have a bigger system design problem, but I suppose, it's one of those "one time only" problems that wind up running one a week.

The key is to avoid (or reduce) the reads to the 1MM rec file.

First off, I'd look around to see if the 1MM data exists in a database or VSAM (keyed) file and do 50 direct reads from there.

If you must read thru the 1MM file take advantage of its existing sort seq (if any) and only sort the 50 rec file in 1MM order. Also use the 50 rec file as the "controlling" file (i.e. EOF on that file ends the process).
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Tue May 31, 2005 6:01 pm    Post subject:
Reply with quote

I think that the better way is a binary search that in each case require 7 or less access to determine the existence of the record and so, in your case you will have not than 350 access to satisfy your search.
The only clause is that both files must be sorted for the same key.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts fuzzy compare Martylin JCL & VSAM 6 Thu Mar 30, 2017 2:45 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


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