DEFINE INDEX

DEFINE INDEX is the clause in IDCAMS DEFINE CLUSTER that lets you specify the index component of a Key Sequenced Data Set (KSDS). When you define a cluster with INDEXED, VSAM creates both a data component and an index component. The INDEX clause is where you can give the index component a name and, where supported, set index-specific attributes such as control interval size or volume placement. This page explains what DEFINE INDEX is, when it is used, and what you can specify in it. Only KSDS has an index component; ESDS, RRDS, and LDS do not use the INDEX clause.

What Is the INDEX Clause?

In a DEFINE CLUSTER command for an INDEXED (KSDS) cluster, you specify cluster-level parameters (NAME, INDEXED, RECORDSIZE, KEYS, FREESPACE, space, etc.) and then optionally the DATA clause and the INDEX clause. The INDEX clause defines or qualifies the index component: the physical dataset that holds the sequence set and index set—the structures that map key values to control intervals in the data component. The index component has its own catalog entry and its own space on DASD. Programs never open it directly; they open the cluster, and VSAM uses the index component internally to resolve key-based reads and to maintain key order when inserting. If you omit the INDEX clause, IDCAMS still creates the index component and assigns it a default name (often cluster-name.INDEX).

When to Use the INDEX Clause

You use the INDEX clause when: (1) you want the index component to have a specific catalog name (e.g. for naming standards or so LISTCAT shows a recognizable name), or (2) you need to set attributes that apply only to the index component, such as CONTROLINTERVALSIZE or VOLUMES. For example, some installations place the index on a faster volume or a different volume from the data. If you do not care about the index name or index-level options, you can omit the INDEX clause and let IDCAMS use defaults. The cluster will still work; key-based access will still use the index.

Syntax of the INDEX Clause

The INDEX clause comes after the DATA clause (or after the cluster parameters if you omit DATA). It is used only for INDEXED clusters. General form:

jcl
1
2
3
4
5
6
7
8
9
10
DEFINE CLUSTER ( - NAME(cluster-name) - INDEXED - ... other cluster parameters ...) - DATA ( ... ) - INDEX ( - NAME(index-component-name) - [ CONTROLINTERVALSIZE(n) ] - [ VOLUMES(volser) ])

NAME is the catalog name for the index component. CONTROLINTERVALSIZE sets the size of each index control interval in bytes. Index CIs hold sequence set or index set entries (key + pointer pairs). The default or system-chosen size is often sufficient. VOLUMES places the index component on the specified volume(s); this can be used to separate index and data for performance or availability.

Parameters in the INDEX Clause

Common INDEX clause parameters
ParameterDescription
NAME(index-component-name)The catalog name for the index component. Use when you want a specific name (e.g. cluster.INDEX) instead of the default. Must be unique in the catalog.
CONTROLINTERVALSIZE(size)CI size in bytes for the index component. Index CIs hold sequence set or index set entries. Default or system-chosen size is often used if not specified.
VOLUMES(volser)Volume serial(s) for the index component. Lets you place the index on different volumes than the data component for performance or availability.

The index component does not store application records; it stores index records (separators and pointers). So parameters like RECORDSIZE or FREESPACE that apply to the data component are not used in the INDEX clause. The index is built and maintained automatically by VSAM when you insert, delete, or update records in the cluster.

Example: DEFINE CLUSTER with DATA and INDEX

A full KSDS definition that names both components:

jcl
1
2
3
4
5
6
7
8
9
10
DEFINE CLUSTER ( - NAME(MY.CUST.KSDS) - INDEXED - RECORDSIZE(200 200) - KEYS(15 0) - FREESPACE(15 10) - CYLINDERS(30 10)) - DATA (NAME(MY.CUST.KSDS.DATA) CONTROLINTERVALSIZE(8192)) - INDEX (NAME(MY.CUST.KSDS.INDEX) CONTROLINTERVALSIZE(4096))

Here the cluster MY.CUST.KSDS has a data component named MY.CUST.KSDS.DATA with 8KB CIs and an index component named MY.CUST.KSDS.INDEX with 4KB CIs. The index CI size can be smaller than the data CI size because index entries are typically smaller than data records. Programs reference only MY.CUST.KSDS; the component names are for catalog and administration.

INDEX Clause and Other VSAM Types

For NONINDEXED (ESDS), NUMBERED (RRDS), or LINEAR (LDS), there is no index component. Do not specify an INDEX clause for those cluster types. If you do, IDCAMS may reject the command or ignore it depending on implementation. The INDEX clause is meaningful only when the cluster is defined with INDEXED (KSDS).

Relationship to the Data Component

The data component holds the records in key order; the index component holds the map from keys to data CIs. When you define a KSDS, both are created. The DATA clause names and optionally configures the data component; the INDEX clause names and optionally configures the index component. Both are created in the same DEFINE CLUSTER; you cannot define an index component separately or add it later to a non-indexed cluster. To get key-based access you must define the cluster as INDEXED from the start.

Key Takeaways

  • DEFINE INDEX is a clause inside DEFINE CLUSTER that defines or qualifies the index component of a KSDS.
  • Only INDEXED (KSDS) clusters have an index component; do not use INDEX for ESDS, RRDS, or LDS.
  • The INDEX clause is optional; if omitted, IDCAMS creates the index with a default name.
  • Use INDEX to give the index component an explicit NAME or to set CONTROLINTERVALSIZE or VOLUMES.
  • The index component stores the sequence set and index set; programs open the cluster, not the index.

Explain Like I'm Five

The index is like the index at the back of a book: it tells you which page (control interval) to look at for a given key. When you order a KSDS cabinet (cluster), you get a drawer for the papers (data) and a separate index drawer. DEFINE INDEX is where you give that index drawer its own label (name) or say how it is organized. You don't have to—the system can label it for you—but if you want a specific name or layout, you use DEFINE INDEX. Only keyed cabinets have an index drawer; the others don't.

Test Your Knowledge

Test Your Knowledge

1. For which VSAM type do you use the INDEX clause?

  • ESDS
  • RRDS
  • KSDS
  • LDS

2. What does the index component store?

  • The actual data records
  • Key-to-CI mapping (sequence set and index set)
  • Catalog entries
  • JCL

3. Is the INDEX clause required when defining a KSDS?

  • Yes, always
  • No; IDCAMS creates the index with a default name if omitted
  • Only for alternate indexes
  • Only when using REPRO
Published
Updated
Read time4 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: IBM z/OS 2.5 documentationSources: IBM DFSMS Access Method Services, z/OS VSAM documentationApplies to: z/OS 2.5