Document revision date: 19 July 1999
[Compaq] [Go to the documentation home page] [How to order documentation] [Help on this site] [How to contact us]
[OpenVMS documentation]

OpenVMS User's Manual


Previous Contents Index

11.8 Optimizing a Sort or Merge Operation

There are several ways in which you can improve the efficiency of a Sort or Merge operation, based on your sorting environment. Use the /STATISTICS qualifier with the SORT or MERGE command to get information about the variables in your sorting environment.

After you examine the statistics display, consider any of the optimization options presented in the following sections.

When you enter the SORT or MERGE command with the /STATISTICS qualifier, you see output similar to the following:


$ SORT/STATISTICS PAGEANT.LIS DOCUMENT.LIS
                  OpenVMS Sort/Merge Statistics 
 
Records read:           3 (1)     Input record length:       26 
Records sorted:         3        Internal length:           28 
Records output:         3        Output record length:      26 
Working set extent: 16384 (2)     Sort tree size:            42 
Virtual memory:       392        Number of initial runs:     0 
Direct I/O:            10        Maximum merge order:        0 
Buffered I/O:          11        Number of merge passes:     0 
Page faults:          158 (3)     Work file allocation:       0 (4)
Elapsed time: 00:00:00.54        Elapsed CPU:      00:00:00.03 (5)

As you examine the fields, note the following:

  1. Records read
    Lists the number of records that were read during a Sort operation. See Section 11.8.2 for information on selectively omitting records from a Sort operation.
  2. Working set extent
    Shows how many blocks are reserved to perform the sort operation. See Section 11.8.4 for information on making your working set larger.
  3. Page faults
    Shows how many times the operating system has transferred parts of your process from physical memory to your paging device. See Section 11.8.4 for more information on preventing paging.
  4. Work file allocation
    Shows how much disk space is reserved for your work file. See Section 11.8.3 for more information on work files.
  5. Elapsed CPU
    Shows how much CPU time the operating system took to process the sort operation. See Section 11.8.1 for information on saving time by choosing different methods of sorting.

11.8.1 Sorting Process

Sort defines four processes for sorting data internally: record, tag, address and indexed. (The high-performance Sort/Merge utility supports only the record process. Implementation of tag, address, and index processes is deferred to a future OpenVMS Alpha release.) RECORD is the default process. The type of process you choose affects the performance of the Sort operation as well as storage requirements. See the Section 11.2.6 for information about the different sort processes.

Before you select a sorting process, consider the following:

11.8.2 Omitting Records and Fields

From a specification file, you can improve Sort efficiency by using the /CONDITION, /INCLUDE, and /OMIT qualifiers to process only those records needed in the output file. (The high-performance Sort/Merge utility does not support specification files. Implementation of this feature is deferred to a future OpenVMS Alpha release.) You can also use specification file qualifiers to reformat records, omitting unnecessary fields from the output file. These qualifiers are not available as command line qualifiers.

11.8.3 Assigning Work Files

During a Sort operation, records from the input file are read into memory. If the allocated memory cannot hold all the records, Sort transfers the sorted data to one or more temporary work files. Merge does not use work files.

You can increase sort efficiency by changing the number of work files and by assigning them to specific devices:

Consider the following when you assign work files to devices:

11.8.4 Modifying the Working Set Extent

If Sort requires work files (for example, if you are sorting a large file), a larger working set can increase sort efficiency. However, if your system is used heavily, it might be unable to allocate all the pages in the working set extent to your process. This can result in paging, which occurs when the operating system transfers parts of a process between physical memory and memory on a paging device; only the active part of the process remains in the physical memory. To avoid excessive paging, you can decrease the working set extent for your process. (Use the SET WORKING_SET command to decrease the working set extent.)

11.9 Summary of Sort/Merge Qualifiers

The following list describes command qualifiers used with the SORT and MERGE commands. To use a command qualifier, include the qualifier immediately after the SORT or MERGE command.

/[NO]CHECK_SEQUENCE

/COLLATING_SEQUENCE=sequence

/[NO]DUPLICATES

/KEY=(POSITION:n,SIZE:n[,field,...])

/PROCESS=type

/SPECIFICATION=filespec

(The high-performance Sort/Merge utility does not support this qualifier. Implementation of this feature is deferred to a future OpenVMS Alpha release.)

/[NO]STABLE

/[NO]STATISTICS

/WORK_FILES[=n]

11.9.1 Input File Qualifier

The following input qualifier should be included immediately after the input file specification in the SORT or MERGE command line:

/FORMAT=(RECORD_SIZE:n,FILE_SIZE:n)

11.9.2 Output File Qualifiers

The following output qualifiers can be used with the SORT and MERGE commands. To use an output file qualifier, include the qualifier immediately after the output file specification in the SORT or MERGE command line.

/ALLOCATION=n

/BUCKET_SIZE=n

/CONTIGUOUS

/FORMAT=(type:n[,...])