Tuning DFSORT means setting the right options so your sort has enough memory and sortwork to complete without failing (e.g. ICE046A) and, when possible, runs faster. The main levers are the file size estimate (FILSZ), memory size (SIZE or MOSIZE), sortwork (DYNALLOC or SORTWK DDs), region size in JCL, and options such as EQUALS and blocksize. This page gives an overview of these tuning parameters, how they interact, and when to adjust them.
| Parameter | Purpose |
|---|---|
| FILSZ | Estimate of input/data size; DFSORT uses it to plan sortwork and allocation. |
| SIZE / MOSIZE | Maximum memory for sort objects; more memory can reduce sortwork I/O. |
| DYNALLOC | Dynamic allocation of sortwork datasets; needs FILSZ and possibly limits. |
| EQUALS / NOEQUALS | Preserve order of equal keys (stable sort) vs allow reorder. |
| REGION | JCL: address space for the step; must be large enough for requested memory. |
| BLKSIZE (SORTWK) | Block size for sortwork; larger can reduce I/O; multiple of LRECL. |
| SKIPREC / STOPAFT | Limit input for testing or sampling; can reduce resource use. |
OPTION FILSZ tells DFSORT how much data to expect (input size or total data volume). DFSORT uses it to plan how much sortwork to allocate and how to organize the sort. When DFSORT cannot determine size from the dataset (e.g. E15 exits, tapes, or dynamic allocation), a good FILSZ is critical. Too low and you risk ICE046A or resource abends; too high and you may waste DASD. Specify FILSZ in the format your product expects (e.g. FILSZ=E followed by bytes or record count). For variable-length records, scaling by average/max LRECL may be needed. See the FILSZ estimation tutorial for details.
SIZE or MOSIZE (product-dependent name) controls the maximum size of the memory objects DFSORT uses for sorting. More memory means more data can be held in central storage before being written to sortwork, which can reduce I/O and merge passes and improve elapsed time. It can be specified as a percentage of available storage (e.g. MOSIZE=50) or as a fixed value in MB. The step REGION in JCL must be large enough for DFSORT to use this memory; otherwise the effective size is capped by the region. See the SIZE tuning and memory usage tutorials.
Sortwork datasets (SORTWK) hold data that does not fit in memory during the sort. You can provide them explicitly with SORTWK01, SORTWK02, … DDs, or let DFSORT allocate them dynamically with OPTION DYNALLOC. With DYNALLOC, DFSORT uses the FILSZ estimate (and product logic) to decide how much space to request. Insufficient sortwork leads to ICE046A. For large sorts, ensure FILSZ is realistic and that DYNALLOC limits (or the number/size of SORTWK DDs) are high enough. See the sortwork datasets and dynamic allocation tutorials.
EQUALS requests a stable sort: when two records have the same sort key, their relative order in the input is preserved in the output. NOEQUALS allows DFSORT to reorder equal keys, which can be slightly more efficient. Use EQUALS when the order of equal keys matters (e.g. keeping the first of duplicate keys first). See the EQUALS/NOEQUALS tutorial for details.
The REGION parameter in the EXEC statement sets the maximum address space for the step. DFSORT allocates its memory objects, buffers, and control blocks within this region. If you specify SIZE=256M but REGION=64M, the step cannot use 256 MB. For large sorts, set REGION=0M (system default) or a value that is at least as large as the memory you intend DFSORT to use (SIZE/MOSIZE plus overhead). Otherwise tuning SIZE may have no effect.
For sortwork datasets, BLKSIZE and LRECL affect I/O efficiency. Larger blocks mean fewer I/Os per unit of data; BLKSIZE should be a multiple of LRECL and within device limits. Tuning blocksize is covered in the blocksize tuning tutorial. The number of SORTWK datasets (or DYNALLOC volume count) also affects how much work space is available; too few can cause capacity problems.
SKIPREC skips the first n input records; STOPAFT stops after processing n records. They are useful for testing (e.g. run with STOPAFT=1000 to verify logic without processing the full file) and can reduce resource use during development. They are not primary performance tuning for production but help limit work during testing.
For a large production sort: (1) Provide a realistic FILSZ so DFSORT can plan allocation. (2) Set SIZE/MOSIZE to allow sufficient memory (e.g. percentage or fixed MB). (3) Ensure enough REGION so the step can use that memory. (4) Rely on DYNALLOC or provide enough SORTWK DDs so sortwork is sufficient. (5) Use EQUALS only if you need stable sort. (6) Tune BLKSIZE on sortwork if I/O is a bottleneck. If you get ICE046A, increase sortwork and/or FILSZ first; then review SIZE and REGION.
Imagine sorting a huge pile of cards. You need a big table (memory) to lay out the cards you’re working on, and extra boxes (sortwork) when the table is full. The table size is like SIZE; the boxes are like SORTWK. If someone tells you how many cards there are (FILSZ), you know how many boxes to get. If your room (REGION) is too small, you can’t have a big table. Tuning means giving the sort enough “table” and “boxes” and the right “room” so it can finish without running out of space.
1. Which OPTION parameters are most important for tuning a large sort?
2. What does EQUALS vs NOEQUALS affect?
3. Why specify a larger region for a DFSORT job?
4. What is the risk of setting FILSZ too low?
5. How do BLKSIZE and LRECL on SORTWK affect tuning?