IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Advantage of MERGE over SORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Wed Jan 25, 2012 11:34 pm
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
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 Developer


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

PostPosted: Thu Jan 26, 2012 12:17 am
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 26, 2012 1:16 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 26, 2012 1:25 pm
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu Jan 26, 2012 1:39 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Jan 26, 2012 3:18 pm
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Thu Jan 26, 2012 3:30 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Merge two VSAM KSDS files into third ... JCL & VSAM 6
Search our Forums:

Back to Top