REORG is a parameter of the Index command, and can be used to reorganize index files directly, without reading the master file. This can greatly speed up the re-indexing process, especially on network systems, because the already sorted portion of the index file will not be sorted again. If the index file has already been fully sorted, BR will read only the header record and then quit the re-indexing process immediately.
It is important to note that the REORG parameter will generally not cause new records to be added to the index file. It is the responsibility of the programmer to be sure that index file's overflow area is updated with added records before REORG performs its operation. This can be done by always opening the index file when writing to the master file.
There are three cases in which INDEX with the REORG parameter will completely build an index file:
- When the index file does not exist.
- When the specified file is not an index file.
- When any of the key starting pos or key length parameters stored in the header record are different from those specified in the INDEX REORG command.