Documente Academic
Documente Profesional
Documente Cultură
VSAM Day 1
Course schedule
UNIT VSAM Intro
Topics:
Access Methods VSAM Introduction VSAM Organization Control Interval
Access Methods
What is an access method? Most computer applications are designed to manipulate data and generate results based on the data.
DASD
Access methods are ways to maximize the efficiency of data storage and retrieval.
Access Methods
Continued
VSAM Introduction
VSAM stands for Virtual Storage Access Method Used to access the data sets quickly and effectively. Used to organize, store, catalog, retrieve and delete data sets.
ROLE OF VSAM
VSAM acts as an interface between processing programs and the operating system.
VSAM groups individual data records into larger units in order to reduce the number of I/O requests required when sequentially retrieving records.
These larger units are transferred between the Direct Access Storage Device (DASD) and virtual storage by the operating system.
1. VSAM interprets the processing programs logical request and determines what services are desired. 2. VSAM makes the required Input or Output (I/O) request(s) to the operating system. 3. The operating system performs the physical I/O operation(s) between the device and the storage. 4. VSAM locates and extracts the desired data before returning it to the processing program.
Operating System VSAM Processing Program
ADVANTAGES OF VSAM
Data can be accessed faster.
Records can be inserted in more efficient manner.
Deletion of records results in them being physically removed from the disk.
Records can be accessed sequentially or randomly. VSAM data sets are device independent.
DISADVANTAGES OF VSAM
VSAM data sets require more storage space than other types of data sets.
VSAM data set require additional free space that must be embedded in them.
ESDS is best suited for applications where most processing is done sequentially.
In a KSDS, records can be processed both sequentially and randomly using their key field values.
The advantages of KSDS are: Sequential processing is useful for retrieving records in the sorted form
A VSAM data set can be moved without affecting the RBAs of its records.
Continued
100
200
300
Record 1
Record 2
Record3
Cluster
What is a cluster?
A cluster is the collection of physical data sets that make up one logical data set. The concept of a cluster is more suited for a KSDS.
Continued
Cluster (contd)
A KSDS cluster has two data sets.
KSDS.CLUSTER
One data set holds the actual data records. The other data set contains an index component.
KSDS.INDEX KSDS.DATA
Cluster (contd)
With an ESDS, an RRDS and an LDS, the cluster name and the data set component and a cluster consists of only a single physical data set:
Related Data Sets
Cluster
name
both
A B C
What is a control interval? o A control interval is the amount of data transferred between the device and virtual storage.
o When a record is read from or written to a data set, VSAM groups individual data records into larger units of storage. These units of storage are called control intervals. o Size of a control interval should be minimum 512 bytes and increased by multiples of 512 upto a limit of 8 K. Beyond that the increments should be 2KB up to a maximum of 32KB.
o Control interval size = n * 512 or n * 2048 where n is between 1 to 16.
R1 R1 R1 Unused Space 4 2 0 3 4 0 2 2 0
9 8 0
1 0 5 5
Free space
Data Contains the actual data processed by the program Control interval description field Contains the information about the free space within the CI.
1 0 5 5
An RDF is a three byte field that is used to define the location and length of a record or a group of records.
The RDFs immediately precede the CIDF, at the end of the control interval.
R1 R2 R3 R4 432 432 432 432 Unused Space (1055)
432
ESDS Organization
In an ESDS records are stored in the order in which they are written and can be read in the same order. The characteristics of ESDS are summarized below: Records are stored sequentially. Records can be of fixed or variable length. Records are physically grouped into control intervals. Control intervals contain control information along with data.
Control Interval 1 R1 R2 R3 R4 Control Interval 2 R5 R6 R7 R8 Control Interval 3 R1 R2 R3 R4
//SAMP003B JOB ,,CLASS=M, // MSGLEVEL=(1,1),NOTIFY=SAMP003,TIME=(1) //EXEC1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD *
DEFINE CLUSTER ( NAME(SAMP003.ESDS.CLUSTER) TRACKS(2,1) CISZ(512) RECORDSIZE(80,80) NONINDEXED ) DATA(NAME(SAMP003.ESDS.DATA)
) /*
Control Intervals
Control Interval 1 R1 R2 R3 R4 R5 Control Interval 2 R6 R7 R8 Control Interval 3 R1 R2 R3 R4
How is the size of a control interval determined? The size of a control interval is determined when the data set is defined. The size can be defined in either of the following ways: The size can be defined with the DEFINE CLUSTER command that defines the data set. VSAM selects the size that best utilizes DASD storage.
Continued
Control Info
CIDF (contd)
Control Interval 1 CIDF
1 0 2 0
What does CIDF contain? The CIDF contains the following two values, each two bytes long: The first value indicates where the unused space in the control interval begins, stored as a displacement from the beginning of the control interval. The second value indicates the length of the unused space.
Case 1: Consider a case, where no two consecutive records have the same length and the control interval has unused space.
Case 2: Consider a case, where all records in a control interval are of the same length and the control interval has unused
space.
Case 3: Consider a case, where records are of variable length, but some consecutive records are of same length.
How is space wasted in a control interval? The example shows how a data set, containing records of 3000 bytes and 5000 bytes, would be stored if a 5K (5120 bytes) control interval is used. The following inferences can be made from the given example: Only a single record of either size can fit in a control interval For every 3000-byte record, 2113 bytes are unused and for every 5000-bytes record, 113 bytes are unused As a result, just for 5 records, 6565 bytes of space is Continued wasted
3000
3000
5000
How can you avoid wastage of space? There are two solutions to prevent space wastage in control intervals. They are: Increasing the control interval size Spanned records
Continued
Increasing the Size of Control Intervals In this case, a 16K control interval might result in a less wasted space, depending on the proportion and sequence of the 3000byte and 5000-byte records. However, as VSAM always reads the CIDF into main storage, this solution is not very efficient.
Continued
3000
3062
1038
3000
3000
3062
1938
Spanned Records
The problem of wasted space can be resolved by reducing the control interval size and directing VSAM to split records over control intervals. Records which are split between control intervals are called spanned records. A spanned record, thus, is a logical record contained in more than one block. In the given case, if 3K intervals are used with spanned records, instead of 5K control intervals, the total amount of wasted space will be reduced to 4234 bytes.