Choosing file organization and access mode

There are several guidelines you can use to determine which file organization and access mode to use in an application.

About this task

Consider the following guidelines when choosing file organization:

  • If an application accesses records (whether fixed-length or variable-length) only sequentially and does not insert records between existing records, a QSAM or VSAM sequential file is the simplest type.
  • If you are developing an application for z/OS® UNIX file system that sequentially accesses records that contain only printable characters and certain control characters, line-sequential files work best.
  • If an application requires both sequential and random access (whether records are fixed length or variable length), a VSAM indexed file is the most flexible type.
  • If an application inserts and deletes records randomly, a relative file works well.

Consider the following guidelines when choosing access mode:

  • If a large percentage of a file is referenced or updated in an application, sequential access is faster than random or dynamic access.
  • If a small percentage of records is processed during each run of an application, use random or dynamic access.

Table 1. Summary of file organizations, access modes, and record formats of COBOL files
File organization Sequential access Random access Dynamic access Fixed length Variable length
QSAM (physical sequential) X     X X
Line sequential X     X1 X
VSAM sequential (ESDS) X     X X
VSAM indexed (KSDS) X X X X X
VSAM relative (RRDS) X X X X X
  1. The data itself is in variable format but can be read into and written from COBOL fixed-length records.