KSDS - IBM Mainframe

To explain the concept of alternate index, we will use the sample customer KSDS that we created in the previous section. If we recall, the customer number is the primary key of the data set and by giving this primary key we can access any record belonging to any customer. However, suppose we do not know the customer number and we need to access a record by the customer name. How can we accomplish this?

To understand the solution to this problem, suppose we have a second KSDS with customer name as the key and the only other field in the KSDS being the customer number which is the prime key of the base KSDS. We will have as many records in the second KSDS as we had in the base KSDS because for each record in the base cluster, we have a record in the second KSDS.

Alternate Index

Alternate Index

Now, to access a customer by name, we would first access the alternate index using its key, the customer name, and then use the customer number corresponding to this record to access the full record from the base cluster This is illustrated in the above figure. Therefore, the alternate index can be considered to be kind of a cross-reference to the base table.

Since the second data set i.e. the alternate index cluster has only two fields, it does not occupy much space on the disk compared to the base cluster. It should be noted that the alternate index is also a KSDS and also has a data and index component. However, as far as the maintenance of data on the Alternate index is concerned, VSAM takes care of all that for you.

Since accessing a record through the alternate index involves the reading of two KSDS each with its own data and index components, retrieval through alternate indexes take twice as much time as retrieval through the prime key of the base cluster. We can have up to 253 alternate indexes for a base cluster. However, it is not prudent to have more than 5 at the most for efficiency considerations.

Another important point to note is that although an ESDS does not have a prime key, an alternate index can be defined over an ESDS. The*only difference is that, where the prime key of a KSDS would have been stored in an alternate index over a KSDS, in the case of an ESDS it is the relative byte address of the corresponding record in the base cluster that is stored. The only restriction to its use is that it cannot be used in a batch environment, but is supported in C1CS.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM Mainframe Topics