Indexing Fields: The INDEX Subcommand

To index a field after you have entered data into the data source, use the INDEX subcommand. You can index fields in addition to those previously specified in the Master File or since the last REBUILD or CREATE command. The only requirement is that each field specified must be described with the FIELDTYPE=I (or INDEX=I) attribute in the Master File.

The INDEX option uses the operating system sort program. You must have disk space to which you can write. To calculate the amount of space needed, add 8 to the length of the index field in bytes and multiply the sum by twice the number of segment instances

(LENGTH + 8) * 2n

where:

n

Is the number of segment instances.

You may decide to wait until after loading data to add the FIELDTYPE=I attribute and index the field. This is because the separate processes of loading data and indexing can be faster than performing both processes at the same time when creating the data source. This is especially true for large data sources.

Sort libraries and workspace must be available. The REBUILD allocates default sort work space in z/OS, if you have not already. DDNAMEs SORTIN and SORTOUT must be allocated prior to issuing a REBUILD INDEX.



Procedure: How to Use the INDEX Subcommand

The following steps describe how to use the INDEX subcommand:

  1. Add the FIELDTYPE=I attribute to the field or fields you are indexing in the Master File.
  2. Initiate the REBUILD facility by entering:
    REBUILD

    The following options are available:

    1. REBUILD        (Optimize the database structure)
    2. REORG          (Alter the database structure)
    3. INDEX          (Build/modify the database index)
    4. EXTERNAL INDEX (Build/modify an external index database)
    5. CHECK          (Check the database structure)
    6. TIMESTAMP      (Change the database timestamp)
    7. DATE NEW       (Convert old date formats to smartdate formats)
    8. MDINDEX        (Build/modify a multidimensional index)
  3. Select the INDEX subcommand by entering:
    INDEX or 3
  4. Enter the name of the Master File in which you will add the FIELDTYPE=I or INDEX=I attribute.
  5. Enter the name of the field to index. If you are indexing all the fields that have FIELDTYPE=I, enter an asterisk (*).

Statistics appear when the REBUILD INDEX procedure is complete, including the field names that were indexed and the number of index values included.



Example: Using the INDEX Subcommand in Windows

The following procedure:

1. REBUILD 
2. INDEX 
3. EMPLOYEE 
4. EMP_ID
  1. Initiates the REBUILD facility.
  2. Specifies the INDEX subcommand.
  3. Specifies the name of the Master File.
  4. Specifies the name of the field to index.

    The field will be indexed and the appropriate statistics will be generated.


WebFOCUS