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
 

 

Advantage of MERGE over SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Wed Jan 25, 2012 8:46 pm    Post subject: Advantage of MERGE over SORT
Reply with quote

What MERGE is doing, that can also be done by using SORT.
Then what is the specific advantage of using MERGE ?
Will it provide any performance more than the SORT as the records are already SORTED ? If yes, apart from performance what are other advantages of using MERGE ?
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 25, 2012 11:34 pm    Post subject:
Reply with quote

MERGE requires that each input data set is already in sorted order.
SORT has no such requirement.

In general, MERGE is more efficient than SORT because MERGE does NOT require the use of intermediate storage or work data sets as SORT does.
Back to top
View user's profile Send private message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Wed Jan 25, 2012 11:53 pm    Post subject:
Reply with quote

Thanks. But when we specify keys in merge, the output will be the sorting of input files based on the keys. In order for sorting them merge requires intermediate storage ,right ?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jan 26, 2012 12:17 am    Post subject:
Reply with quote

No. Since the records in each file are already in sorted order by the specified keys for a MERGE, DFSORT does NOT have to SORT the records. MERGE is a different process which does NOT require intermediate storage.
Back to top
View user's profile Send private message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Thu Jan 26, 2012 12:42 pm    Post subject:
Reply with quote

Need clarification....
Code:
Input 1
1
2
5
Input 2
3
4
Final Output of merge
1
2
3
4
5


The above is for the SORT card
MERGE FIELDS=(1,1,BI,A)-->sorting takes place in ascending order.
Intermeddiate storage is required to SORT the above 2 input files which are already in SORTED order. Please correct me if i am incorrect....

Code:
MERGE FIELDS=COPY
it may not require the intermediate storage because it is not doing amy kind of SORTing.
For this the output will be
Code:
1
2
5
3
4
No shuffling of records take place.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 26, 2012 1:16 pm    Post subject:
Reply with quote

FIELDS=COPY means there will be no sorting or merging, just a copy of the input will be made. Its all in the manual.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Thu Jan 26, 2012 1:25 pm    Post subject: Reply to: Advantage of MERGE over SORT
Reply with quote

Suresh K,

I don't know how much longer you are going to refuse to either read the manual or read what people say.

Why don't you sit yourself down at a terminal, run some sort steps with that data and those sort cards and then try to explain to yourself without recourse to anyone else or the manual why the results are not as you predict?

Eventually to realise that everyone else is right, and you are wrong, very severely, on several levels.

MERGE, with or without values on FIELDS=, does not do any sorting.
Back to top
View user's profile Send private message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Thu Jan 26, 2012 1:33 pm    Post subject:
Reply with quote

Yes Peter. I went through the manual.
The above explanation is for Frank Yaeger's quote:
Quote:
MERGE is a different process which does NOT require intermediate storage
. When keys are specified, MERGE will sort both inputs and produce output. In this case sorting process of MERGE should require intermediate storage....
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 26, 2012 1:39 pm    Post subject:
Reply with quote

From the manual :

Example 1
MERGE FIELDS=(2,5,CH,A),FILSZ=29483
FIELDS
The control field begins on byte 2 of each record in the input data sets. The
field is 5 bytes long and contains character (EBCDIC) data that has been
presorted in ascending order.

Reading comprehension is an art.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Jan 26, 2012 3:18 pm    Post subject: Reply to: Advantage of MERGE over SORT
Reply with quote

Quote:
When keys are specified, MERGE will sort both inputs and produce output. In this case sorting process of MERGE should require intermediate storage....


what is that you do not understand in the concept
files in input to MERGE must be already sorted ( on the merge key ) ?
icon_evil.gif

why don' t You try to run a simple merge with the records out of sequence
and see what happens ?
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Jan 26, 2012 3:30 pm    Post subject:
Reply with quote

I reckon Suresh K is missing the very simplistic view

Code:
 READ FILE1
  READ FILE2
   DO while File1_KEY1 < File2 KEY2
      WRITE from File1_Rec
      READ File1
   end
   WRITE from File2_Rec
   &c


... no sorting, just straightforward read/write based on which key should be written next...


Garry.
Back to top
View user's profile Send private message
sureshmurali
Warnings : 1

New User


Joined: 25 Nov 2010
Posts: 70
Location: Sivakasi, India

PostPosted: Thu Jan 26, 2012 3:50 pm    Post subject:
Reply with quote

Thanks Garry... Now i understood. This is what i wanted for.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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