Choosing a Page Size
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. With your answers, you can select a page size that best fits your file.
Optimum Page Size For Minimizing Disk Space
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. (For more generalized information about page size, see Page Size.)
The transactional database engine always stores a minimum of 2 bytes of overhead information in every record (as a usage count for that record). The transactional database engine 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 record overhead required without record compression, depending on the characteristics of your file.
1VAT: variable-tail allocation table
2na: not applicable
The following table shows how many bytes of record overhead required when using record compression, depending on the characteristics of your file.
1VAT: variable-tail allocation table
2na: not applicable
The following table shows how many bytes of page overhead are required depending on the page type.
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 17 and Table 18.
1
2
3
4
5
6
7
8
Using the physical record length, you now can determine the file’s optimum page size for data pages.
The transactional database engine stores the fixed length portion of a data record in the data pages; however, it does not break the fixed-length portion of a record across pages. Also, in each data page, the transactional database engine stores overhead information (see Table 17 and 18). You must account for this additional overhead when determining the page size.
A file contains unused space if the page size you choose minus the overhead information amount is not an exact multiple of the physical record length. You can use the formula to find an efficient page size:
Unused bytes = (Page Size minus Data Page Overhead per Table 17 and Table 18) mod (Physical Record Length)
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. The supported page size varies with the file format. See Table 21. If the internal record length (user data + record overhead) is small and the page size is large, the wasted space could be substantial .
Optimum Page Size Example
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.
As the table above indicates, if you select a page size of 512, only 2 records can be stored per page and 114 to 118 bytes of each page are unused depending on the file format. 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. Those same 21 records would result in over 2 KB of lost space with a page size of 512.
If you have a very small physical record length, most page sizes will result in very little wasted space. However, pre-8.x file versions have a maximum limit of 256 records per page. In that case, if you have a small physical record length, and if you choose a larger page size (for example, 4,096 bytes), it will result in a large amount of wasted space. For example, Table 22 shows the behavior of 14 byte record length for a pre-8.x file version.
2
4
0
Minimum Page Size
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, add the values specified in Table 23.
The table uses a 9.5 file format as an example.
1
2
3
4
Select any valid 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 eight key segments defined in a file using a 512 page size.