Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Calculating the size of an ISAM file

The size of a file can be calculated in the same way for both NK-ISAM and K-ISAM. First, the number of data blocks is calculated from the record length, the usable block size and the number of records.


Usable block size:

RECSIZE <= (n * 2048 (100 - PAD) / 100)

==> usable block size = n * 2048 (100 - PAD) / 100

(n * 2048 (100 - PAD) / 100) <= RECSIZE <= n * 2048

==> usable block size = RECSIZE

n

blocking factor

PAD

PAD value (see PAD operand of the FILE macro)

RECSIZE

Record length

Size of the data section:

Number of records per data block = (Usable block size) / RECSIZE

Number of data blocks = (Records per file / Records per data block)


For NK-ISAM, the number of overflow blocks must also be estimated. This is dependent on the record length:


Overflow blocks:

Number of overflow blocks = i * Number of data blocks

i = 0

for RECSIZE <= n * 2032 - 16

i = 1

for RECSIZE > n * 2032 - 16


In sequentially created NK-ISAM files, each primary index block can hold an average of about 200 primary index entries. The size of an NK-ISAM file can thus be estimated as follows:


Size of file:

Number of PAM pages = Number of data blocks * (BLKSIZE + i + 0.005)

i = 1 / i= 0 takes account of overflow blocks (see above).

For NK-ISAM files, the total number of primary index blocks in a file can be considered to be approximately the same as the number of primary index blocks in the lowest primary index level. The following tables simplify the estimation of the sizes of NK-ISAM files.

For NK-ISAM files created sequentially, each primary index block holds about 200 primary index entries (due to key compression); this results in the values shown in the following table:

Number of data blocks

Number of primary index levels

0 - 200
200 - 40000
40000 - 8000000

1
2
3

Table 50: Calculation of primary index levels for sequentially created NK-ISAM files

For files created non-sequentially, the number of primary index levels increases faster than for sequentially created files, due to the block splitting involved. If there is more than one primary index level, each primary index block contains an average of about 160 index entries.

Number of data blocks

Number of primary index levels

0 - 200
200 - 32000
32000 - 5120000

1
2
3

Table 51: Calculation of primary index levels for non-sequentially created NK-ISAM files

For a file with secondary keys, the number of secondary index blocks can be estimated with the aid of the following formula. This formula takes into account the fact that an attempt is made to fill the secondary index blocks to a level of 75%. This percentage is only an average value. In some cases, this figure cannot be achieved.


Secondary index blocks for secondary key i:

Number of PAM pages =
Number of data blocks * (P-KEYLEN + 8 + hi * (S-KEYLENi + 8)) / 1512

PAM pagesi

PAM pages for the secondary index blocks for secondary key i.

P-KEYLEN

Length of the primary key of the file.

hi

                               

Relative frequency with which different values occur in the file for secondary key i: if, for example, there are on average 10 records with the same value in secondary key i, then hi = 0.1

S-KEYLENi

Length of secondary key i.


The total number of secondary index blocks for all secondary keys in the file is then the sum of the values determined for all defined secondary keys:


Secondary index blocks for a file with n secondary keys:

Number of PAM pages = Number of PAM pages + . . . + Number of PAM pages n


K-ISAM

For K-ISAM files, the number of primary index entries per index block depends on the key length:

Number of index entries per primary index block = 1024 / (KEYLEN + 4)

This formula takes into account the fact that a primary index block cannot be more than 50% full. The total size of a K-ISAM file is then calculated as follows:

Size of file:

Number of PAM pages = Number of data blocks * (BLKSIZE + ((KEYLEN + 4) / 1024))

KEYLEN: Key length.