View previous topic :: View next topic
|
Author |
Message |
sureshmurali Warnings : 1 New User
Joined: 25 Nov 2010 Posts: 70 Location: Sivakasi, India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
sureshmurali Warnings : 1 New User
Joined: 25 Nov 2010 Posts: 70 Location: Sivakasi, India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
sureshmurali Warnings : 1 New User
Joined: 25 Nov 2010 Posts: 70 Location: Sivakasi, India
|
|
|
|
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....
it may not require the intermediate storage because it is not doing amy kind of SORTing.
For this the output will be
No shuffling of records take place. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
sureshmurali Warnings : 1 New User
Joined: 25 Nov 2010 Posts: 70 Location: Sivakasi, India
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10889 Location: italy
|
|
|
|
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 ) ?
why don' t You try to run a simple merge with the records out of sequence
and see what happens ? |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
sureshmurali Warnings : 1 New User
Joined: 25 Nov 2010 Posts: 70 Location: Sivakasi, India
|
|
|
|
Thanks Garry... Now i understood. This is what i wanted for. |
|
Back to top |
|
|
|