INDEXED is the DEFINE CLUSTER keyword that creates a Key-Sequenced Data Set (KSDS). When you specify INDEXED, the cluster has two components: a data component that holds records in ascending key order, and an index component (sequence set and index set) that allows fast access by primary key. INDEXED is one of four organization types you can choose when defining a VSAM cluster; the others are NONINDEXED (ESDS), NUMBERED (RRDS), and LINEAR (LDS). You use INDEXED when you need to find records by key, maintain records in key order, and support insert, update, and delete by key. This page explains what INDEXED does, how it differs from the other organization types, what you must specify with it (including KEYS), and how to define and use a KSDS.
In DEFINE CLUSTER, the organization type determines the kind of VSAM dataset you create. INDEXED means "key-sequenced": every record has a primary key (a field you define with KEYS(length offset)), and VSAM keeps records in ascending order by that key. To find a record, you supply the key and VSAM uses the index to locate the control interval that contains that record, then returns it. You can also read records sequentially in key order. Because the dataset is organized by key, you can insert new records (VSAM places them in key order, possibly triggering CI or CA splits), update records in place (REWRITE), and delete records (freeing space for reuse). All of this depends on the index component, which is created and maintained automatically when you use INDEXED.
You must specify exactly one of INDEXED, NONINDEXED, NUMBERED, or LINEAR. Each produces a different dataset type with different components and access rules. INDEXED gives you a KSDS: key-based access and key order. NONINDEXED gives you an ESDS: no key, records in the order they were written (entry sequence), access by relative byte address (RBA) or sequential; no insert in the middle and no physical delete. NUMBERED gives you an RRDS: fixed-length records in slots, access by relative record number (RRN). LINEAR gives you an LDS: byte-addressable storage with no record structure, used by products like Db2. For most application files where you look up records by an identifier (customer number, order ID, account number), INDEXED (KSDS) is the right choice.
| Keyword | Type | Components | Key | Access |
|---|---|---|---|---|
| INDEXED | KSDS | Data + index | Required (KEYS) | By key, sequential in key order |
| NONINDEXED | ESDS | Data only | None | By RBA, sequential in entry order |
| NUMBERED | RRDS | Data only | None (RRN) | By RRN, sequential |
| LINEAR | LDS | Data only (no CI records) | None | Byte offset |
When you use INDEXED you must also specify KEYS(length offset). The key is what the index is built on; without it, IDCAMS cannot create the index. KEYS(length offset) defines the key length in bytes (1–255) and the byte offset in each record where the key starts. You also need RECORDSIZE (minimum and maximum record length, or fixed length) so that VSAM knows the record layout. Optionally you specify FREESPACE (to reduce splits), space allocation (CYLINDERS, TRACKS, or RECORDS), VOLUMES, SHAREOPTIONS, and DATA/INDEX component names. If you omit DATA and INDEX, IDCAMS generates default component names (typically cluster-name.DATA and cluster-name.INDEX).
For an INDEXED cluster, IDCAMS creates two components. The data component holds the logical records. Records are stored in control intervals (CIs) and control areas (CAs), and within each CI they are in ascending key order. The index component holds the sequence set (one entry per data CI, with the high key and a pointer to that CI) and, if needed, one or more index set levels (separator keys and pointers) so that VSAM can find the right data CI with few I/Os. You do not open the components directly; you open the cluster by name, and VSAM uses both the data and index components to satisfy key-based and sequential requests.
In the DEFINE CLUSTER command, you code INDEXED as the organization keyword. It appears in the cluster-level parameter list along with NAME, RECORDSIZE, KEYS, and space. Example:
12345678910DEFINE CLUSTER ( - NAME(USERID.MASTER.CUSTOMER.KSDS) - INDEXED - RECORDSIZE(300 300) - KEYS(12 0) - FREESPACE(15 10) - CYLINDERS(20 5) - VOLUMES(SYSDA)) - DATA (NAME(USERID.MASTER.CUSTOMER.KSDS.DATA)) - INDEX (NAME(USERID.MASTER.CUSTOMER.KSDS.INDEX))
INDEXED makes this a KSDS. KEYS(12 0) defines a 12-byte primary key at offset 0. RECORDSIZE(300 300) means fixed-length 300-byte records. FREESPACE(15 10) reserves 15% of each CI and 10% of each CA for inserts. The cluster is allocated 20 primary cylinders with 5 secondary. The DATA and INDEX clauses name the components explicitly; you can omit them to use defaults.
Use INDEXED (KSDS) when: (1) You need to read a record by a key value (e.g. customer ID, order number). (2) You need records in sorted order by that key for sequential processing or reporting. (3) You need to insert new records, update existing ones, or delete records by key. (4) You may want an alternate index later to access the same data by another key (e.g. by name instead of ID). Use NONINDEXED (ESDS) when records are append-only (logs, audit trails) and you access by position (RBA) or sequentially in write order. Use NUMBERED (RRDS) when you address records by slot number (RRN) and all records are the same length. Use LINEAR only for special cases (e.g. LDS for Db2). For typical master files, lookup tables, and keyed transaction files, INDEXED is the standard choice.
INDEXED is like telling the computer: "This file is a filing cabinet where every folder has a label (the key), and the folders are always sorted by that label. When I ask for the folder labeled SMITH, you use the index to find it quickly. When I add a new folder, you put it in the right place so the order stays correct." The other options are different: NONINDEXED is like a stack of papers in the order you wrote them (no labels, you find by position). NUMBERED is like a row of numbered boxes. LINEAR is like one long tape. For most "look up by name or ID" files, INDEXED (the filing cabinet with labels) is what you want.
1. Which DEFINE CLUSTER keyword creates a KSDS?
2. When you use INDEXED, what else must you specify?
3. Can you ALTER a cluster to change INDEXED to NONINDEXED?