---
title: "VSAM: KSDS, ESDS, LDS, RRDS Differences and Their Uses"
description: "Top differences of VSAM RRDS, KSDS, ESDS and LDS"
url: https://srinimf.com/2012/05/16/vsam-ksds-esds-lds-rrds-and-their-uses/
date: 2012-05-16
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2012/05/pexels-photo-5239741.jpeg?fit=1880%2C1255&ssl=1
categories: ["VSAM"]
tags: ["KSDS vs ESDS", "LDS vs RRDS", "VSAM files"]
type: post
lang: en
---

# VSAM: KSDS, ESDS, LDS, RRDS Differences and Their Uses

[](http://biganalytics.me)The name VSAM states that it is all about storage and Access method. Read my [previous post](http://srinimf.com/2015/02/07/vsam-file-reading-in-cobol-program/) [on VSAM](https://srinimf.com/2016/02/06/5-stunning-benefits-of-vsm-ksds/) basics.

## Here are the Differences: KSD, ESDS, RRDS and LDS

**KSDS: **

- Each record has one or more key fields.
- With [key field](https://srinimf.com/2018/08/13/cobol-indexed-vs-sort-top-differences-you-need-to-know/) we can access the data randomly. KSDS provides for both Random and Sequential access
- IMS uses KSDS datasets extensively.
- These records can be of Variable in length.
- It consists of Data component and [Index component](https://srinimf.com/2023/11/01/how-a-record-in-a-ksds-is-randomly-accessed-by-primary-key/).
- KSDS extensively being used for Master records – Inventory, Customer, Employee
- KSDS is less efficient because of Index overhead

**ESDS:**

- These are sequential files.
- Records are written in sequentially.
- These datasets extensively being used in IMS, DB2 and CICS
- These records are in sequence
- Records can be accessed directly by (RBA)
- The records in ESDS are often in either Ascending or Descending order
- It is possible, we can also [access records](https://srinimf.com/2023/11/25/5-tricky-questions-on-vsam-alternate-index/) through [Alternative Index](https://srinimf.com/2016/10/04/the-best-way-to-delete-vsam-secondary-index/)

---

Advertisements

---

**RRDS:**

- These records can be accessed by relative record numbers. By Record#1 , Record#2…..etc.
- It is possible to read records randomly with Index. However,here records are stored in slots. These slots internally read in sequence. So, sequential access is more efficient than access by using Index.
- Drawback of RRDS is vacant slots. This is main drawback wastage of space, and RRNs are empty.

## ***Read:*** [IBM Mainframe Handbook](https://amzn.to/2JxFmIs)

**LDS:**

- These records are byte-stream datasets.
- Db2 uses extensively this type of datasets.
- Very rarely used by application programs.
- The records are written in byte format, so these are called byte-stream datasets.

**VSAM Re-usable datasets:**

VSAM lets you define an ESDS, a KSDS, or an RRDS as a reusable data set. When a reusable data set is opened for output, VSAM resets the data set so all of its records are ignored and the records of the new data set overwrite the old records.

With a reusable ESDS, for example, VSAM keeps track of the highest relative byte address (RBA) that is used by the data set. Then, when the data set is opened for input or for I/O, VSAM reads all the records sequentially until it reaches the highest RBA. But when the data set is opened for output, VSAM resets the RBA to zero so the old records can be overwritten by the new records. By using a reusable data set, you are able [to define](https://srinimf.com/2021/05/01/vsam-files-useful-parameters-to-specify-in-idcams-define/) a [VSAM data](https://srinimf.com/2016/04/20/how-cics-rls-mode-handles-during-files-updates/) set just once and use it repeatedly.

Recommended Links:

- [Relation Between Alternate Index-Build-Path](http://srinimf.com/2015/04/07/vsam-relation-between-alternate-index-path-and-base/)

Keep Reading

- [How to Read VSAM File Randomly in COBOL](https://srinimf.com/2020/03/29/7-quick-tips-on-mainframe-vsam-files/)DateMarch 29, 2020
- [How to Define Various VSAM Clusters with IDCAMS](https://srinimf.com/2021/05/01/vsam-files-useful-parameters-to-specify-in-idcams-define/)DateMay 1, 2021
- [How to Handle VSAM files in PL1 language](https://srinimf.com/2017/08/07/pli-these-are-the-best-ways-for-vsam-files/)DateAugust 7, 2017

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F05%2F16%2Fvsam-ksds-esds-lds-rrds-and-their-uses%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2012%2F05%2Fpexels-photo-5239741.jpeg%3Ffit%3D1200%252C801%26ssl%3D1&description=VSAM%3A%20KSDS%2C%20ESDS%2C%20LDS%2C%20RRDS%20Differences%20and%20Their%20Uses)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/05/16/vsam-ksds-esds-lds-rrds-and-their-uses/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/05/16/vsam-ksds-esds-lds-rrds-and-their-uses/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/05/16/vsam-ksds-esds-lds-rrds-and-their-uses/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/05/16/vsam-ksds-esds-lds-rrds-and-their-uses/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20VSAM%3A%20KSDS%2C%20ESDS%2C%20LDS%2C%20RRDS%20Differences%20and%20Their%20Uses&body=https%3A%2F%2Fsrinimf.com%2F2012%2F05%2F16%2Fvsam-ksds-esds-lds-rrds-and-their-uses%2F&share=email)
-

### Like this:

Like Loading…
