The SWAMI
of VSE/VSAM

 

Space Allocation Questions and Answers
How can I predict the number of logical records within a Control Interval (CI)?

First, we have to know what goes into Control Intervals (CIs).

VSAM Data Control Intervals contain:

Logical Records
Logical records are loaded into a CI beginning at its left (or low addressed) end.
Control Iinformation
At the right (or high addressed) end, a four-byte Control Interval Definition Field (CIDF) is inserted. This principally indicates the position and size of the free space, if any, within the CI.

Following the CIDF (immediately to its left, or lower in address) will be the first Record Descriptor Field (RDF). This describes the length of the first (leftmost, lowest addressed) logical record within the CI.

If there is a second logical record within the CI, there will be a second RDF. If the second logical record is the same length as the first, then the second RDF will be a counter indicating that the second record (and third, etc.) are the same length as the preceeding record. On the other hand, if the second record is of a different length than the first, a normal RDF will be used specifying the length of the second record. This same decision is made as each additional logical record is added -- either update the counter if the new logical record is the same length, or add a new normal RDF.

In the case of spanned records, the RDF will refer to the record segment contained within the CI.

Free Space
Finally, there may be free space within the CI, between the right end of the last logical record and the left end of the last RDF. Again, the CIDF indicates the position and length of the free space within the CI.

The minimum amount of free space within a CI can be specified in the DEFINE CLUSTER command's FREESPACE parameter. It indicates the minimum percentage of the CISIZE (rounded up to the next whole byte) that is to be left free during sequential insertion processing (e.g. during file load, extend, or during mass sequential insertions of a series of records).

For example,

CISIZE(4096)
Logical record length = 200 bytes fixed length
FRSPC(10 10)
 
Then:
There will be one CIDF of 4 bytes, and two RDF of 3 bytes each,
for a total of 10 bytes of control information.
There will be 10% of 4096 = 410 bytes of reserved free space.
There will be 420 bytes of CI space that cannot be loaded with
logical records... and 3576 bytes that can be loaded with logical records.
3576 / 200 = 17 logical records will be inserted in each CI being loaded.
4086 - 3400 = 686 bytes of free space will exist in each CI being loaded.

In the case of variable length records, your ability to predict the number of logical records inserted into a CI depends on your knowledge of the sizes of the records inserted into the specific CI. Even if other records in other CIs happen to have differing lengths, the records being inserted into a particular CI might be of one length, so you can set bounds on the number of RDFs in a CI -- one if only one record is stored in a given CI, two if more than one, and as many as there might be logical records.

In the example case above, suppose the records were of variable length, but averaged 200 bytes in length. Then I could need as many as 20 RDFs (one for each possible record that could be inserted). In this case, the potential 18 additional RDFs would occupy at most 54 additional bytes of control information, and the total number of records inserted and number of additional records that could be directly inserted into the available free space would be unchanged.

No -- I didn't give you a formula to figure this out. I did show you what VSAM inserts and how big it is, so you can figure it out yourself.

Still want a formula? For fixed-length logical records:

 
[NumRecs] = (CISize - 10 - Ceil(FRSPC% * CISize)) / [RecSize]
 
Where:
NumRecs == the number of logical records to be inserted at load
CISize  == the defined Control Interval Size
10      == constant for sum of length of CIDF + 2 RDFs
Ceil    == function that returns the integer value rounded up
FRSPC%  == the defined Control Interval Freespace percentage
RecSize == the actual record size
 

This works for all cases when more than one logical record is inserted into a CI. In the cases when only one logical record is inserted, the factor 10 above should be changed to 7.

It has been my experience that application designers and programmers do not know the actual average logical record length nor the distribution of those lengths unless they actually have built the system and measured the result.

   
 
Up to the
Q and A
Page
Up to the
Allocation
Q and A Page
E-Mail
The Swami
Go to
The Swami's
Home
 

This entire site -- including all its pages and content --
are the intellectual property of and copyright © 2002-2003 by
Dan Janda, theswami@epix.net