Sort Performance Considerations

The sorting procedure analyzes the request being processed and the amount of sort memory available in order reduce the amount of disk I/O. The sort strategy is controlled by the specifics of the request and the values of the SORTMATRIX and SORTMEMORY parameters.


The SORTMATRIX parameter controls whether to employ in-memory sorting with decreased use of external memory. The syntax is




Creates a single sort matrix of up to 2048 rows, and uses a binary search based insertion sort with aggregation during retrieval. The maximum number of rows in this matrix has been determined to provide the best performance for this type of sort. If the sort matrix becomes full, it is written to a file called FOCSORT on disk, the in-memory matrix is emptied, and retrieval continues, writing to FOCSORT as many times as necessary. When the end of data is detected, the remaining rows are written to FOCSORT and the merge routine merges all of the sort strings in FOCSORT (which, in extreme cases, may require multiple merge phases), while also completing the aggregation.


Creates a large matrix or multiple small matrices in memory, when adequate memory is available as determined by the SORTMEMORY parameter. LARGE is the default value. The goal of this strategy is to do as much sorting as possible in internal memory before writing any records to disk. Whether disk I/O is necessary at all in the sorting process depends on the amount of memory allocated for sorting and the size of the request output. If the amount of SORTMEMORY is not large enough to meaningfully make use of the LARGE strategy, the sort will default to the SMALL strategy. The LARGE strategy greatly reduces the need for disk I/O and, if disk I/O is required after all (for very large output), it virtually eliminates the need for multiple merge phases.


The SORTMEMORY parameter controls the amount of internal memory available for sorting. The syntax is




Is the positive number of megabytes of memory available for sorting. The default value is 512.