FastSort Manual

Optimizing Sort Performance
FastSort Manual429834-003
9-12
Calculating Data Stack Space
VLM can also increase performance for sorts that do require scratch files. For sorts
that require an intermediate merge pass, FastSort uses the additional memory to store
partial information. The additional storage space reduces reads and writes to scratch
files.
How VLM Affects Statistics
When VLM is on, the FastSort statistics format changes slightly.
For interactive FastSort, BUFFER PAGES changes from an INT to an INT(32) value
when VLM is on. In this case, BUFFER PAGES can have a value greater than 32,767,
the maximum extended memory segment you can manually specify. BUFFER PAGES
can also be -1 as a result of VLM.
For programmatic FastSort, a parameter in the SORTMERGESTATISTICS array tells
FastSort to return the larger statistics format when VLM is on. If the parameter flag1
is present and set to 1, FastSort converts BUFFER PAGES to an INT(32) value before
placing it in the statistics array. If you specify a value other than 0 or 1 for flag1,
FastSort returns error 150 (INVALID STATISTICS FLAG VALUE SPECIFIED). For
applications that use VLM, set flag1 to 1 to get accurate statistics when BUFFER
PAGES is greater than 32,767.
For more information about SORTMERGESTATISTICS, see Section 5, Using FastSort
System Procedures.
Calculating Data Stack Space
If you invoke FastSort from an application program, sort complexity determines the
amount of data stack space FastSort requires. Follow the guidelines in the following
table to calculate data stack space requirements.
To allocate this additional space in an application, use one of the following methods:
For a TAL application, use the DATAPAGES compiler directive during compilation.
Specify DATAPAGES 64 to allocate the maximum amount.
For all applications, use the Binder SET EXTENDSTACK command after
compilation. Specify 64 PAGES to allocate the maximum amount.
When you run the program, specify 64 pages for the MEM option of the RUN
command. If you run the program from another application, specify 64 for the
PROCESS_CREATE_ or NEWPROCESS[NOWAIT] memory-pages parameter.
Move user data from the user data segment to an extended data segment to free
up more data stack space for the call to SORTMERGESTART.
Operation Description Additional Space
Simple Less than 5 keys, no subsorts, 1 input file 2 pages
Medium Greater than 5 keys, either subsorts or multiple input files 3 pages
Complex Greater than 5 keys, subsorts, multiple input files 4 pages