|
All pages in a data file are the same size. Therefore, when you determine the size of the pages in your file, you must answer the following questions:
The following sections guide you through answering these questions. Once you have these values, you can select a page size that best fits your file.
Before you can determine the optimum page size for your file, you must first calculate the file's physical record length. The physical record length is the sum of the logical record length and the overhead required to store a record on a data page of the file.
The MicroKernel always stores a minimum of 2 bytes of overhead information in every record (as a usage count for that record). The MicroKernel also stores an additional number of bytes in each record, depending on how you define the records and keys in your file.
The following table shows how many bytes of overhead you must add to the logical record length to obtain the physical record length (based on how you define the records and keys for your file). You can also find a summary of this record overhead information in Table 5-5 and Table 5-6 .
|
Task Description
|
Example
|
|---|---|
|
1. Determine the logical record length. For instructions, refer to Calculating the Logical Record Length 1
|
72
|
|
2. Add 2 (two) for the record usage count (do not add this for file formats earlier than 6.x).
|
72 + 2 = 74
|
|
3. For each linked-duplicatable key, add 8 (eight).2 The example file has one linked-duplicatable key.
|
74 + 8 = 82
|
|
4. For each reserved duplicate pointer, add 8 (eight). The example file has no reserved duplicate pointers.
|
82 + 0 = 82
|
|
5. If the file allows variable-length records, add 8 (eight) for pre-8.x files and 10 (ten) for 8.x or later files. (The example file does not allow variable-length records.)
|
82 + 0 = 82
|
|
6. If the file uses blank truncation, add one of the following. If the file does not use blank truncation, add nothing.
w Add 4 (four) if the file uses VATs.
w Add 2 (two) if the file does not use VATs.
|
82 + 0 = 82
|
|
PHYSICAL RECORD LENGTH
|
82
|
|
1For files with variable-length records, the logical record length refers only to the fixed-length portion of the record.
2When calculating the number of bytes for duplicatable keys, include only 8 bytes for each linked-duplicatable key. The MicroKernel does not allocate duplicate pointer space for keys defined as repeating duplicatable at creation time. By default, keys that allow duplicates created at file creation time are linked-duplicate keys.
|
Note
For files with compressed records, the data page format is different. A compressed record's entry on a data page consists of overhead information of 5 bytes for pre-6.x, 7 bytes for 6.x and 7.x, and 9 bytes for 8.x files, pointers for duplicate keys, reserved duplicate pointers (if any), and a 4-byte record-length field (if the file uses VATs). The record's user-defined data is compressed and stored on variable pages. If the example Employee file (7.x format) is created with compression, the physical record length would be 7+8=15.
Using the physical record length, you now can determine the file's optimum page size for data pages.
The MicroKernel stores up to 256 records in each data page of the file; however, it does not break the fixed-length portion of a record across pages. Also, in each data page, the MicroKernel stores 6 bytes of overhead information (8 bytes for an 8.x file). You must account for this additional overhead when determining the page size.
A file contains unused space if the page size you choose, minus 6 or 8 bytes (for overhead information), is not an exact multiple of the physical record length. You can use the following formula to find an efficient page size:
To optimize your file's use of disk space, select a page size that can buffer your records with the least amount of unused space. Page size must always be a multiple of 512 bytes up to 4,096 bytes. If the internal record length (user data + overhead) is small and the page size is large, the wasted space could be substantial (up to 2,554 bytes, considering a 4,096 page size and an internal record length of 6).
Consider an example in which the physical record length is 194 bytes. The following table shows how many records can be stored on a page and how many bytes of unused space remains on a page for each possible page size.
Note
These calculations are for a file format earlier than 8.x; you would need to subtract 8 instead of 6 in the calculation for an 8.x file.
As the table indicates, if you select a page size of 512, only 2 records can be stored per page and 118 bytes of each page are unused. However, if you select a page size of 4,096, 21 records can be stored per page and only 16 bytes of each page are unused.
If you have a very small physical record length, most page sizes you could choose will result in very little wasted space. However, as the following table shows using a physical record length of 14 bytes, if you choose a very large page size (for example, 4,096 bytes), the MicroKernel's limit of storing a maximum of 256 records on a page will result in a large amount of wasted space.
The following table shows how many bytes of record overhead you will have when using uncompressed data pages, depending on the characteristics of your file.
The following table shows how many bytes of record overhead you will have when using compressed data pages, depending on the characteristics of your file.
The page size you choose must be large enough to hold eight key values (plus overhead). To find the smallest page size allowable for your file, you must perform the following tasks outlined in Table 5-7.
Select any page size that is equal to or greater than the result. Remember that the page size you select must accommodate the size of any keys created after file creation. The total number of key segments may dictate the minimum page size. For example, you can only have seven key segments defined in a file using a 512 page size.
|
Chapter contents
Prev topic: Calculating the Logical Record Length
|