MainframeMaster

DFSORT Tuning Parameters

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.

Performance Optimization
Progress0 of 0 lessons

Overview of Key Parameters

Main DFSORT tuning parameters
ParameterPurpose
FILSZEstimate of input/data size; DFSORT uses it to plan sortwork and allocation.
SIZE / MOSIZEMaximum memory for sort objects; more memory can reduce sortwork I/O.
DYNALLOCDynamic allocation of sortwork datasets; needs FILSZ and possibly limits.
EQUALS / NOEQUALSPreserve order of equal keys (stable sort) vs allow reorder.
REGIONJCL: 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 / STOPAFTLimit input for testing or sampling; can reduce resource use.

FILSZ: File Size Estimate

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 / MOSIZE: Memory for Sort

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.

DYNALLOC and Sortwork

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 and NOEQUALS

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.

REGION

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.

Blocksize and SORTWK

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 and STOPAFT

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.

Putting It Together

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.

Explain It Like I'm Five

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.

Exercises

  1. Your sort fails with ICE046A. Which parameters would you check and in what order?
  2. You set OPTION MOSIZE=50 (50% of available storage) but the sort still uses very little memory. What JCL parameter might be limiting it?
  3. When would you use EQUALS instead of NOEQUALS?

Quiz

Test Your Knowledge

1. Which OPTION parameters are most important for tuning a large sort?

  • Only SORT FIELDS
  • FILSZ (file size estimate), SIZE/MOSIZE (memory), and DYNALLOC (sortwork)—together they determine whether DFSORT has enough work space and memory to complete efficiently
  • Only INCLUDE
  • Only EQUALS

2. What does EQUALS vs NOEQUALS affect?

  • Output format only
  • Whether records with equal sort keys keep their original relative order (EQUALS keeps it; NOEQUALS may not). EQUALS can use slightly more resources but gives stable sort
  • Only variable-length
  • Only MERGE

3. Why specify a larger region for a DFSORT job?

  • To increase SORTOUT size
  • To give the sort step more address space for memory objects (SIZE/MOSIZE), buffers, and control blocks—without enough region, DFSORT may not use the memory you request
  • Only for COPY
  • Region does not affect sort

4. What is the risk of setting FILSZ too low?

  • Output is truncated
  • DFSORT under-allocates sortwork, which can lead to sort capacity exceeded (ICE046A) or resource abends (ICE083A, SB37-04)
  • Sort runs faster
  • FILSZ is ignored when low

5. How do BLKSIZE and LRECL on SORTWK affect tuning?

  • They do not affect sort
  • Larger blocks reduce I/O count and can improve performance; BLKSIZE should be a multiple of LRECL and tuned for the device. Too small blocks mean more I/O; too large may waste buffer space
  • Only LRECL matters
  • Only for SORTOUT