IMS Access Methods: HSAM, HISAM, HDAM, HIDAM Explained

TT
TopicTrick

IMS provides four primary access methods for full-function databases, each with different performance characteristics, storage organisation, and use cases. Choosing the right access method is one of the most important database design decisions because it cannot be changed without unloading and reloading the entire database.

Overview of the Four Access Methods

Access MethodFull NameStorageRoot AccessBest For
HSAMHierarchical Sequential Access MethodSequentialSequential onlyArchived data, batch sequential
HISAMHierarchical Indexed Sequential Access MethodVSAM KSDSBy key or sequentialSimple hierarchies, moderate volume
HDAMHierarchical Direct Access MethodOSAM/VSAMVia hashHigh-volume random access
HIDAMHierarchical Indexed Direct Access MethodOSAM/VSAMVia separate indexMixed random/sequential, most common

HSAM — Hierarchical Sequential Access Method

HSAM is the simplest IMS access method. Data is stored sequentially — all segments in hierarchical sequence key order in a flat sequential dataset (PS or BSAM).

How it works: Segments are written end-to-end in hierarchical order. Root segments and all their dependents appear together, followed by the next root and its dependents.

Retrieval: Always sequential — you must read from the beginning. There is no way to jump directly to a specific root occurrence.

Updates: HSAM databases are effectively read-only in online mode. Updates require a full unload-modify-reload cycle using batch programs.

Use cases: Archival data, input files for batch programs, data extract files. HSAM is rarely used for production transactional databases.

HISAM — Hierarchical Indexed Sequential Access Method

HISAM stores data in VSAM KSDS (Key Sequenced Dataset) for the primary data plus an ESDS (Entry Sequenced Dataset) for overflow. The KSDS is indexed by the root segment key, enabling direct access.

How it works: Root segments and their immediate dependents are packed into KSDS records. Overflow segments (when a root's dependents fill the primary record) are stored in the ESDS with chaining pointers.

Retrieval: Direct access to any root by key (via VSAM index), or sequential processing.

Performance issues: As records overflow to the ESDS, performance degrades. HISAM databases require periodic reorganisation to move overflow data back into the primary KSDS.

Use cases: Small to medium databases with relatively few dependents per root, where both random and sequential access are needed. HISAM is less commonly used in new development — HIDAM is usually preferred.

HDAM — Hierarchical Direct Access Method

HDAM uses a hash algorithm to determine the physical location of root segments. When you insert a root, IMS hashes the root key to compute a relative block number (RAP — Root Anchor Point), placing the segment near that location.

How it works:

  1. Root key is hashed to produce a RAP value
  2. The segment is stored near that RAP in the database
  3. Pointers link parent to first child, and sibling to sibling (hierarchical and twin pointers)
  4. Retrieval by GU uses the same hash to find the approximate location, then follows pointers

Retrieval: Very fast for random access when you know the root key — hash to the RAP, follow pointers to the exact segment. Sequential processing requires reading all blocks, which is less efficient than HIDAM.

Use cases: Databases where the overwhelming majority of access is random (GU by key), root keys have good hash distribution, and sequential full-database scanning is rare.

HDAM parameters:

hlasm
DBD NAME=CUSTDB,ACCESS=HDAM
RMNAME=(DFSHDC40,1,500,2048)

DFSHDC40 is the standard IBM randomising routine. The parameters control the number of RAPs and block size.

HIDAM — Hierarchical Indexed Direct Access Method

HIDAM is the most commonly used IMS access method for production systems. It combines a separate index database with a primary database storing the hierarchical data.

How it works:

  1. A separate HIDAM index database (VSAM KSDS) contains one entry per root occurrence, pointing to the physical location of the root segment in the primary database
  2. Root segments and all dependents are stored with hierarchical pointers (parent-child, twin)
  3. GU calls use the index to find the root quickly, then navigate via pointers

Retrieval: Fast random access (GU by key — look up index, follow pointer) and efficient sequential access (follow twin pointers through roots in key order).

Use cases: Most production IMS databases — HIDAM is the default choice when both random and sequential access are needed and access volumes are high.

HIDAM structure:

hlasm
* Primary database
DBD NAME=CUSTDB,ACCESS=HIDAM
*
* Index database (separate DBD)
DBD NAME=CUSTDBI,ACCESS=INDEX
DATASET DD1=CUSTDBI,DEVICE=3390,SIZE=4096
SEGM NAME=CUSTDBI,BYTES=10,PARENT=0
FIELD NAME=(CUST-KEY,SEQ,U),BYTES=10,START=1,TYPE=C
DBDGEN

The index DBD is referenced in the primary DBD via the LCHILD macro or via the PSBGEN.

Choosing the Right Access Method

Choose HDAM when:

  • Almost all access is random (GU by root key)
  • Sequential processing is rare or not needed
  • Root key values have good hash distribution (no clustering)
  • Maximum random throughput is the priority

Choose HIDAM when:

  • Both random and sequential access are needed
  • You need to process root segments in key sequence
  • You want predictable performance across access patterns
  • This is the safe default for most production databases

Choose HISAM when:

  • The database is small with simple hierarchies
  • Both key access and full sequential scan are needed
  • Administrative simplicity is valued over peak performance

Choose HSAM when:

  • The data is truly sequential (input/output files)
  • No random access is ever needed
  • The database is effectively read-only between batch cycles

Frequently Asked Questions

Q: Can I change the access method of an existing IMS database? Yes, but it requires unloading all data with the IMS database unload utility, regenerating the DBD with the new access method, recreating the datasets, and reloading the data. This is a significant operation for large databases and requires careful planning and downtime.

Q: What is the performance difference between HDAM and HIDAM in practice? For pure random access (GU by root key), HDAM is typically slightly faster because it avoids the extra index lookup — the hash directly locates the block. For mixed workloads with sequential processing, HIDAM is usually better overall. The difference in modern z/OS systems with large memory for buffer pools is often small enough that HIDAM's flexibility makes it the preferred choice.

Q: What is a DEDB and how does it relate to these access methods? DEDB (Data Entry Database) is the IMS Fast Path access method — a separate category from the four full-function access methods. DEDBs use a different physical structure optimised for very high-throughput short transactions. DEDBs are covered in the IMS Fast Path module.


Part of the IMS Mastery Course — Module 7 of 22.