TSO-ISPF JCL COBOL VSAM DB2 CICS IMS-DB Tools Articles Forum Quiz Interview Q&A

IMS Secondary Indexing

The secondary index in IMS can be used to index a given segment on the basis of any field in that segment or in any physical dependent of that segment. Generally the use of a secondary index is transparent to the application program. Given the existence of a secondary index, the user may process the corresponding data base in the secondary sequence defined by that index. If the index target segment is not the physical root, selecting the secondary sequence will cause a restructuring of the hierarchy, in particular, the index target segment will become the root in this restructuring.

In the secondary sequence, the indexed field acts as the root segment sequence field. The user sees exactly as many data base records as there are segment occurrences containing the indexed field in the physical database. These records are sequenced in ascending order of that field. This resulting rearragement of the database structure is called a secondary data structure.

A secondary index is implemented in the form of a self-contained data base that stores a series of pointers which point to segments in the data base being indexed. Note that the secondary index is a separate data base. So each secondary index is described as a separate DBD. The link between the secondary index database and main database is specified in the DBD. Secondary data structures don’t change the way the data base segments are stored on the disk; they just alter the way DL/I presents those segments to application programs.

The field on which the index is based may actually be a concatenation of up to five fields, not necessarily contiguous, taken in any order.

A Source Segment is the segment from which the value used in the secondary index is taken. It may be a target segment or a physical dependent of the target.

A Target Segment is the segment pointed to by a secondary index. It is the segment that will be retrieved when the index is used.

A Pointer Segment is the segment in the Secondary Index database which contains the index value and a pointer to the target.

PSBGEN requirements for Secondary Indexing:

DL/I will not automatically use the secondary index in the program, unless the proper processing sequence for the database is specified on the PROCSEQ parameter of the PCB macro. If it is not specified, processing is done using the normal hierarchical sequence for the database. For the PROCSEQ parameter, the DBA codes the DBD name for the secondary index database that will be used.

Further explanation of PSBs and how they look like is explained in the respective places of the following examples.

The customer data base is considered to explain the secondary index concept. There are many possible secondary indexes that could be constructed for the database. They are :

  1. Both source and target segments are root segments.

  2. Source segment is dependent and Target segment is Root.

  3. Both source and target segments are dependent segments of Same segment type.

  4. Both source and target segments are dependent segments, but they are of different segment types.

Let us see each type in details in next section.

If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on IBMMainframer Community!

Are you looking for Job Change? Job Portal