Entry sequencing is the way an Entry Sequenced Data Set (ESDS) orders its records: in the exact order they were written. The first record you write is the first record in the file; the second is the second; and so on. There is no key and no reordering. New records are always added at the end (append-only). This is different from a Key-Sequenced Data Set (KSDS), where records are stored in key order and new records can be inserted in the middle. Understanding entry sequencing helps you choose ESDS when you need write-order preservation, logging, or simple append semantics, and avoid it when you need key-based access or insert-in-the-middle. This page explains what entry sequencing is, how ESDS uses it, how it differs from key sequencing, and how to access data in entry sequence.
Entry sequencing means that the physical order of records in the dataset is the same as the order in which they were written (the "entry" order). When your program writes record A, then record B, then record C to an ESDS, the file contains A, then B, then C in that order. No internal key is used to reorder them. The position of a record is determined solely by when it was written relative to the others. So "entry" refers to the act of entering (writing) the record into the file. The sequence is fixed at write time: you cannot later insert a record between A and B without rewriting or reorganizing the file. In practice, with ESDS you do not insert in the middle at all; you only append. So entry sequencing and append-only behavior go together.
ESDS is the only VSAM dataset type that uses pure entry sequencing. When you define a cluster with the attributes of an ESDS (non-indexed, no key), every record is stored in the order it is written. The data component has no index; there is no key field in the record that VSAM uses for ordering. So the only "sequence" is the order of writes. This makes ESDS similar in spirit to a sequential file (like a QSAM file) where you open for output and write records one after another. The difference is that ESDS also allows direct access by relative byte address (RBA): once a record is written, its RBA is fixed, and you can read it later by that RBA without reading from the beginning. So you get both: sequential read in entry order, and random read by RBA. But the underlying order is always entry sequence.
In a KSDS, records are stored in key order. If you write a record with key 50, then key 10, then key 30, VSAM stores them in the order 10, 30, 50 (ascending key). So the physical order is key sequence, not write order. In an ESDS, the same writes would store the records in the order 50, 10, 30 (write order). So the main difference is: ESDS preserves write order; KSDS imposes key order. That leads to other differences. In a KSDS you can insert a new record with key 25 and it will go between 10 and 30; in an ESDS you can only append, so the new record goes at the end. In a KSDS you can find a record by key (random access by key); in an ESDS you have no key, so you find a record by RBA or by scanning sequentially. Choosing ESDS means you care about write order (e.g. audit logs, event streams) or simple append semantics; choosing KSDS means you need key-based access and key order.
| Aspect | Entry sequencing (ESDS) | Key sequencing (KSDS) |
|---|---|---|
| Order of storage | Order in which records were written (first written = first in file) | Order of the key (lowest key first, regardless of write order) |
| Key required | No key; ESDS has no key field | Yes; KSDS has a primary key |
| Insert position | New records only at the end (append) | New records inserted in key order (may be anywhere) |
| Index | No index component | Index component for key lookup |
Entry sequence is useful when the order of events or writes matters. For example, a log file that records transactions in the order they occurred should preserve that order: the first transaction written is the first when you read from the start. With ESDS, reading sequentially from the beginning gives you records in the same order they were written, which is exactly the chronological order of events. Another use is a simple queue or stream: producers append records; consumers read from the beginning (or from a saved RBA) in entry order. Entry sequence is also simpler than key sequence: there is no index to maintain, no splits when inserting (because you never insert in the middle), and no key to define. So ESDS can be more efficient for pure append workloads and when you do not need key-based lookup.
To read an ESDS in entry sequence (write order), you open the file and read sequentially from the beginning. The first READ returns the first record written; each subsequent READ returns the next in write order. You can also position to a specific RBA (e.g. after a previous read or from a stored value) and then read sequentially from there. So entry sequence is the default order when you do sequential read from the start (or from any RBA). You do not specify "entry sequence" in the program; it is the only order the data has. For random access, you use the record's RBA: each record has a fixed RBA from when it was written, and you can READ with that RBA to get the record directly. So you have two access patterns: sequential in entry order, or direct by RBA. There is no "read by key" because ESDS has no key.
Because order is defined by write order, you cannot insert a record in the middle of an ESDS. Inserting between two existing records would change the entry sequence of everything after that point, which ESDS does not support. The only way to add a record is to append it at the end. So the file grows only at the end. If you need to "insert" in the middle for some logical reason (e.g. correct a log), you would typically do it outside VSAM: write a new file with the correct order, or use logical delete and a new record at the end, depending on your application. ESDS does not offer in-place insert; that is a design choice that keeps the structure simple and avoids the cost of index updates and CI/CA splits that KSDS has.
Each record in an ESDS has a relative byte address (RBA): the offset from the start of the file to the start of that record. The RBA is assigned when the record is written and never changes. So the first record has the smallest RBA (after any control information), the second has the next RBA, and so on. Entry sequence and RBA order are the same: reading in ascending RBA order is the same as reading in entry order. So you can think of entry sequence as "order by RBA." When you read sequentially from the beginning, VSAM is effectively returning records in ascending RBA order, which is entry order. When you store an RBA (e.g. after reading a record), you can later reposition to that RBA and read from there in entry order for the rest of the file.
Imagine a notebook where you write one sentence on each line. The first sentence you write is on line 1, the second on line 2, and so on. You never go back and squeeze a new sentence between line 1 and line 2; you only add new sentences at the end. That order—first written, first in the notebook—is entry sequence. The computer does the same with an ESDS: the first record you write is first in the file, and new ones always go at the end.
1. What determines the order of records in an ESDS?
2. Can you insert a record in the middle of an ESDS?
3. Which VSAM type uses entry sequencing?