FastSort Manual

Optimizing Sort Performance
FastSort Manual429834-003
9-2
Using Scratch Files
Manually Creating a Scratch File
You can use the FUP CREATE command to manually create an unstructured scratch
file. You can also programmatically create a scratch file with the CREATE system
procedure. When you manually create a scratch file, you can:
Allocate scratch space before the sort operation begins
Closely control the amount and location of disk space SORTPROG uses
At run time, if an initial scratch file already exists and is unstructured, FastSort uses the
existing file. If you manually create your own scratch file, use the following formula to
calculate scratch file size:
This formula is approximate, and includes 6 bytes per record for overhead. It does not
include scratch block overhead for header information or variations in block size. For a
partitioned scratch file, calculate input-record-count for each partition. For a
permutation or key sort, output-record-length is the total length of all keys. For a
record sort, output-record-length matches the input record length. If you are
sorting or merging in parallel, divide file size by the number of subsort processes.
If FastSort creates the scratch file, it sets MAXEXTENTS to 978 extents. If a scratch
file reaches MAXEXTENTS, FastSort automatically enlarges the file, if possible. The
maximum size of each scratch file extent is 4 KB, or 2048 pages.
If FastSort cannot enlarge the file, SORTPROG tries to create an overflow scratch file
on the current volume. If there is insufficient overflow space on the current volume,
SORTPROG tries to create an overflow scratch file on a suitable volume. If there is
insufficient overflow scratch space on your node, SORTPROG returns FastSort
error 30 (A WRITE HAS FAILED TO A SCRATCH FILE) and stops.
Having FastSort Create a Scratch File
If no scratch file exists when the sort or merge run starts, SORTPROG creates an
initial scratch file for you. SORTPROG uses a formula like the one described in
Manually Creating a Scratch File
on page 9-2 to calculate file size. If the initial scratch
file becomes full, SORTPROG creates overflow scratch files until the sort or merge run
is complete.
For most sort and merge runs, use one of these options to have SORTPROG size and
create initial scratch files for you:
Do not specify a scratch file name. SORTPROG creates an initial scratch file on a
volume selected by DEFINEs or volume characteristics.
output record length–6bytes+input record count