|
You can estimate the number of pages, and therefore the number of bytes required to store a file. However, when using the formulas, consider that they only approximate file size because of the way the MicroKernel dynamically manipulates pages.
Note
The following discussion and the formulas for determining file size do not apply to files that use data compression, because the record length for those files depends on the number of repeating characters in each record.
While the formulas are based on the maximum storage required, they assume that only one task is updating or inserting records into the file at a time. File size increases if more than one task updates or inserts records into the file during simultaneous concurrent transactions.
The formulas also assume that no records have been deleted yet from the file. You can delete any number of records in the file, and the file remains the same size. The MicroKernel does not deallocate the pages that were occupied by the deleted records. Rather, the MicroKernel re-uses them as new records are inserted into the file (before allocating new pages).
If the final outcome of your calculations contains a fractional value, round the number to the next highest whole number.
To estimate the size of your file, perform the following steps:
Page size - 8 in this formula for an 8.x file format):Number of data pages = Number of records / ((Page size - 6) / (Physical record length)To find the physical record length, refer to Table 5-4.
For each key that does not allow duplicates or that allows repeating-duplicatable keys:
Number of index pages = ( Number of records / ((Page size - 12) / (Key length + 8))) * 2For each key that allows linked-duplicatable keys:
Number of index pages = ( Number of unique key values / ((Page size - 12) / (Key length + 12))) * 2The B-tree index structure guarantees at least 50 percent usage of the index pages. Therefore, the index page calculations multiply the minimum number of index pages required by 2 to account for the maximum size.
Number of variable pages = (Total number of records in the file) / (Average number of records whose variable-length portion fits on a single page)
Note
You can gain only a very rough estimate of the number of variable pages due to the difficulty in estimating the average number of records whose variable-length portion fit on the same page.
1 page for each alternate collating sequence page used (if any)
1 page for a referential integrity (RI) page if the file has RI constraints
This new sum represents the estimated total number of logical pages that the file will contain.
Every file has a minimum of two PAT pages; however, to calculate the number of PAT pages in a file, use one of the following formulas:
For pre-8.x file formats:
Number of PAT pages = ( (Sum of pages in Steps 1 through 3) * 4) / ((Page size - 8 bytes for overhead) * 2)For 8.x or later file formats:
Number of PAT pages = ( (Sum of pages in Steps 1 through 3) * 6) / ((Page size - 20 bytes for overhead) * 2)
Size of the pool of unused pages = (Number of keys + 1)This formula applies if tasks execute Insert, Update, and Delete operations only outside transactions. If tasks are executing these operations inside transactions, multiply the average number of Insert, Update, and Delete operations expected in the transactions times the non-transactional figure determined by the formula. Similarly, you must further increase the estimated size of the pool of unused pages if tasks are executing simultaneous concurrent transactions.
|
Chapter contents
Prev topic: Choosing a Page Size
|