Page 1 of 1

What is the difference between internal and external sort?

Posted: Wed Apr 02, 2014 4:26 pm
by Dino
Hello,

Can anybody tell what's the difference between internal and external sort and when to use which one?

Re: What is the difference between internal and external sor

Posted: Wed Apr 02, 2014 5:26 pm
by Robert Sample
Internal sort is invoked within a program while an external sort invokes the SORT program directly (through JCL, for example). Follow site standards as to which to use -- internal sort uses more resources (language overhead) but is used fairly often for convenience.

Re: What is the difference between internal and external sor

Posted: Mon Apr 21, 2014 4:48 pm
by Dino
That means if I call the SORT from COBOL program it's "internal sort" and while in JCL PGM=SORT is "external SORT", right? Are there any difference in them that way, I mean can I call one SORT program in internal and another SORT in external? And why the name "internal/external"?

Re: What is the difference between internal and external sor

Posted: Mon Apr 21, 2014 7:30 pm
by Robert Sample
The same SORT program is invoked for internal and external sorts -- COBOL merely links to the system SORT program when you perform an internal sort. There is slightly more overhead to internal sorts due to the language processing involved, but these days it would be unusual to see any differences unless you are doing a very small sort, or you look at the SMF data to get CPU time to the millionths of a second. The internal and external are in reference to the program -- inside the program (SORT verb) or outside (JCL SORT).

Re: What is the difference between internal and external sor

Posted: Mon Apr 21, 2014 8:06 pm
by William Collins
COBOL has a SORT verb (and a MERGE). It is up to the implementer (IBM in this case) as to how this is implemented.

I don't know if it has been always, but it seems like forever that IBM has implemented it by using the installed SORT product, which makes a lot of sense. I suspect all COBOL implementations do it in an equivalent way (at least to the extent of not implementing compiler code to do the SORT/MERGE).

There are differences between the two as far as performance is concerned. Have a look at compiler option FASTSRT in the Enterprise COBOL manuals. Also consult you SORT documentation. There is a big difference between SORT doing I/O and COBOL doing it. There is also an overhead in transfer of control to/from SORT.

Re: What is the difference between internal and external sor

Posted: Mon Apr 21, 2014 8:26 pm
by Anuj Dhawan
To add to the replies from Robert and William, yes you got this correct:
Dino wrote:That means if I call the SORT from COBOL program it's "internal sort" and while in JCL PGM=SORT is "external SORT", right?
Are there any difference in them that way, I mean can I call one SORT program in internal and another SORT in external? And why the name "internal/external"?
You should note that if you call it internally or externally, the same SORT product will get invoked. It's very rare that you'll find a site where both (or more) SORT products are installed, however, the possibility of having more than one SORT can not be ruled out though - I observed this only at a site where they were migrating from one SORT product to another and kept the one SORT product in a different library to cross check the changes.