REORGANIZE command

From m204wiki
Jump to navigation Jump to search

Rebuilding the Ordered Index

Summary

Privileges
File manager
Function
Rebuilds the Ordered Index together with the Z command

Syntax

REORGANIZE OI [fieldname]

Where:

fieldname A field with the ORDERED attribute.

Examples

The following example deletes the EXPENSE entries in the Ordered Index and writes the updates to rebuild the Ordered Index for EXPENSE into the variable-length deferred update data set:

OPEN TESTFILE,,TAPEVAR REORGANIZE OI EXPENSE

The following example deletes the LAST NAME entries in the Ordered Index and writes the updates to rebuild the Ordered Index for LAST NAME into the variable-length deferred update data set:

OPEN TESTDATA,,TAPE3 REORG OI LAST NAME

The following example deletes all Ordered Index entries in a file and writes the updates to rebuild the Ordered Index into the variable-length deferred update data set:

OPEN TESTFILE,,TAPEVAR REORG OI

Syntax notes

The REORGANIZE command must be issued in file context. Before issuing REORGANIZE, the file must be opened in deferred update mode and a variable-length deferred update data set must be specified.

Usage notes

The REORGANIZE command is used with the Z command to rebuild the Ordered Index. REORGANIZE works with either the entire Ordered Index or a single field that has been defined with the ORDERED attribute. The REORGANIZE command requires exclusive control of the Ordered Index file.

Before REORGANIZE is issued, you must issue an OPEN command that specifies a variable-length deferred update data set for the file. (Refer to the discussion of "OPEN FILE: Opening a file" for information on variable-length data sets.)

The REORGANIZE command writes out deferred update records to the variable-length deferred update data set. These updates are loaded back into the file using the Z command.

The deferred update data set that is created can be very large. A deferred update record is written for each record indexed in the part of the Ordered Index that is reorganized. The length of a record varies with the length of the value indexed.

After running the REORGANIZE command, the reorganized portion of the Ordered Index has no entries. The Z command must be executed to rebuild the reorganized portion of the Ordered Index.

The Z command clusters the segment lists stored on Table D list pages so that all the lists for a given fieldname = value pair are on the same Table D list page, if possible. Generally, clustering the lists will dramatically improves the performance of a FIND that includes a range condition (for example, a FIND ALL RECORDS, where AGE is greater than 20 and less than 60).

Note that if the setting of LRESERVE and NRESERVE are changed before the Z command is issued, the Ordered Index is rebuilt with the newly specified space utilization parameters. Refer to the discussion of "DEFINE FIELD: Field names and attributes" for information on the LRESERVE and NRESERVE attributes.

When it processes REORGANIZE, Model 204 ends any update unit in progress and begins a non-backoutable update unit. For more information about Model 204 update units, see Update units and transactions.