Friday, December 5, 2014

Vsam Basics and Vsam tutorial. (Control interval, Control Area, CIDF, RDF)

This post is just a short writeup for VSAMs.
What is a Vsam file?
Virtual Storage Access Method : This is one type of dataset and  APIs to access the dataset.It is an excellent database to keep the records as they  can be read sequentially,directly or skip sequentially.
We must know that VSAM dataset must always be kept on disk and not on Tape. IBM newly introduced an extension of the VSAM known as  Extended Format Vsam . To an application , a Vsam and extended Vsam are  all same.Extended vsam provides some addition features like compression of the data, sharing, improved performance and allows a maximum data set size if 128 terabytes.
What are control Intervals? 
It is the basic building block for  VSAM dataset. It holds one or more record. Concept is similar to block for sequential and partitioned data sets.  When we read/write record from a vsam file , we read the entire chunk of data, ie the entire CI is moved to memory from DASD, not just the single record
Control Interval which consists of bunch of records.
What are CIDF , RDF in VSAM ?
Apart from keeping records in a CI, Vsam places two additional fields which are needed to manage CI. They are CIDF and RDF.
Unused spce, RDF,CIDF in a VSAM
The Dotted space shows the unused space in a CI.
RDF (Record Descriptor field) stores the length of each record. VSAM with fixed length records needs two RDF. One to keep track of the number of records and the other to count the length of record.For variable length record, there is one per record
CIDF (Control interval definition field) is a 4 byte length field which holds the location and size of unused space in CI.(like the one shown in shaded space)

What is Control Area  ?
Group of CIs make one Control Area (CA).
Group of Control Interval is called as Control Area.

Read here  to check the  Parameters to define a Vsam with IDCAMS

Spanned Records in VSAM and CI Split:
While inserting a record, if  the Record size is larger than the CI size, it can not be stored. In such scenarios,  CI splits happen if the vsam is defined with SPANNED option. The records then span across more than one CI and is known as spanned record. Spanned record occupy the entire CI. Any unused space in the CI can not be used.
Spanned record

No comments:

Post a Comment