Adding a secondary index to a HALDB database

You can add a secondary index to an existing HALDB database.

IMS does not provide a utility to create secondary indexes. The easiest way to add a secondary index is by using a tool, such as the IBM® IMS Index Builder. The IMS Index Builder reads an existing HALDB database and creates one or more secondary indexes for it.

When you add a secondary index, you do not add any entries to the ILDSs because the pointers in the newly created secondary index are accurate. Later, when the partitions are reorganized, IMS adds entries for target segments to the ILDSs.

Adding a secondary index requires new definitions in the indexed database DBD, but does not require changes in the database data sets.

To add a secondary index to a HALDB manually:

Procedure

  1. Create an unload file for the indexed database. You can use HD Reorganization Unload utility (DFSURGU0) or an application program that you write.
  2. Add the secondary index definitions to the indexed database DBD.
  3. Create the DBD for the secondary index.
  4. Define the partitions for the secondary index.
  5. Allocate the data sets for the secondary index.
  6. Initialize the secondary index partitions.
  7. Load the indexed database. You must provide the program to do this. The program reads the file that is created in step 1. When the indexed database is loaded, secondary index entries are created. The creation of the secondary index entries is a random process that can significantly increase the load time.

If you use the DFSURGU0 utility in step 1, the output file contains a header record, one record for each segment, and a trailer record. The segment record includes the segment name and the segment data. Your load program for step 7 might map the records in this file by using the DSECT in the IMS DFSURGUP macro in SDFSMAC.