Thursday, December 22, 2011

VSAM : Calculating ALT INDEX record length

The definition looks like this :

   RECORDSIZE (x1 x2), where x1 is the average record length and  
                             x2 is the maximum record length.     
                                                                  
Record size is computed as follows :                               
------------------------------------                               
For a KSDS :                                                       
RECORD SIZE = 5 + ALTERNATE KEY LENGTH + ( n * PRIME KEY LENGTH )  
   where 'n' is the number of NONUNIQUE PRIME KEYs                
For an ESDS :                                                      
RECORD SIZE = 5 + ALTERNATE KEY LENGTH + ( n * 4 )                 
   where 'n' is the number of NONUNIQUE POINTERs                  
                                                                  
{ The 5 is for 5 bytes in the beginning with the following info :  
 Byte 1 : Housekeeping, the least significant bit of which is used to indicate if it is for KSDS or ESDS - 0 for ESDS, 1 for KSDS            
 Byte 2 : Length of Pointer/Prime Key                             
 Bytes 3-4 : Number of Pointers/Prime keys (ie. no of duplicates) 
 Byte 5 : Length of Alternate Key                                 
}                                                                  

Now, how do we compute the average and Maximum record lengths :      
---------------------------------------------------------------      
    This depends on the number of duplicates we expect the ALT KEY to have. Hence if we don't expect any duplicates the AVG and MAX record length would be the same.
(Usually the AVG record length is computed, assuming there are no duplicates - i.e. n=1. It doesn't make a big difference anyway, since the MAX record length is more important).
                                                                    
eg1) Let us assume the Prime key for a KSDS is defined as KEYS (10 0) and 
   ALT key is defined as KEYS (20 30) in definition for ALT INDEX      

   Assuming there can be a maximum of 50 duplicates, RECORDSIZE should be defined as RECORDSIZE (35 525).                
  i.e. as per the formula :                                         
  AVG rec length = 5 + 20 + (1  * 10) = 35  (assuming no duplicates)  
  MAX rec length = 5 + 20 + (50 * 10) = 525 (assuming 50 duplicates)
   since Prime Key length = 10 and
         ALT Key length   = 20.
                                                                    
eg2) For the same example, if the ALT INDEX was defined with the option UNIQUEKEY (i.e. no duplicates), then AVG and MAX record lengths would have been 35.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.