|
This section includes the following information about pages and how Btrieve handles them:
Files consist of a series of pages. A page is the unit of storage that the MicroKernel transfers between memory and disk. A file is composed of the following types of pages:
All 6.0 and later files have FCR and PAT pages. Standard files also contain data and index pages, and optionally, variable and ACS pages. All 8.0 and later files also have DIR pages. Data-Only Files (page 4-9) contain no index pages. Key-Only Files (page 4-9) contain no data pages.
You specify a fixed page size when you create a file. You can specify any multiple of 512 up to 4,096 bytes. All pages in a file (that is, data pages, index pages, and so on) are the same size.
The page size you specify should satisfy the following criteria:
Each data page contains 6 bytes of overhead information (or 8 bytes in an 8.0 or later file). After that, the MicroKernel stores as many records as possible in each data page, but does not break the fixed-length portion of a record across pages.
The optimum page size accommodates the most records while minimizing the amount of space left over in each data page. Larger page sizes usually result in more efficient use of disk space. However, with the 7.0 and later file formats, a data page cannot have more than 256 records in it. If the internal record length (user data + overhead) is small and the page size is large, the wasted space could be substantial (up to 2554 bytes, considering a 4,096 page size and an internal record length of 6).
Each index page contains 12 bytes of overhead information. After that, the file's index pages must be large enough to accommodate eight keys, plus overhead information for each key. (The overhead information for each key is 8 bytes for keys that allow no duplicates or repeating duplicates, and 12 bytes for keys that use linked duplicates.)
As discussed in Segmentation , the page size you define for a file limits the number of key segments you can specify for that file.
For optimum performance, set the page size to an even power of two-512, 1,024, 2,048, or 4,096 bytes. The internal MicroKernel cache can store multiple size pages at once, but it is divided in powers of 2. Page sizes of 1536, 2560, 3072, and 3584 actually waste memory in the MicroKernel cache. Page sizes that are powers of 2 result in a better use of cache.
To make the most efficient use of modern operating systems, you should choose a larger page size. The smaller page sizes were used when DOS was the prominent operating system (when a sector was 512 bytes and all I/O occurred in multiples of 512). This is no longer the case. Windows 2000/NT moves data around its cache in blocks of 4,096 bytes. The block size of NetWare 4.x formatted partitions are also 4,096 bytes. CD ROM drives are read in blocks of 2,048 bytes.
Btrieve indexes are most efficient with a page size of 4,096. The key will have more branches per node and thus will require fewer reads to find the correct record address. This is important if the application is doing random reads using a key. This is not important when an application accesses the file in a sequential manner either by key or by record.
A good reason for having smaller page sizes is to avoid contention. With fewer records in each page it becomes less likely that different engines or transactions will need the same page at the same time. If a file has relatively few records, and the records are small, you may want to choose a small page size. The larger the file, the less likely contention will happen.
Another potential problem with large page sizes is specific to version 7.0 and later files. There is a maximum of 256 records or variable-length sections that can fit on the same data page. If you have short or compressed records, or short variable-length sections, you can easily reach the limit while you still have hundreds of bytes available on every page. The result is a much larger file than needed. Knowing your record size, you can calculate how big of an issue this is.
To determine Page Size in a Pervasive.SQL data file:
The database designer must choose between these conflicting needs. A reference table that is not changed very often, but is searched or scanned most of the time, should have larger page sizes. A transaction file which is inserted and updated a lot in transaction should have smaller page sizes.
Note
You have to balance these needs.
Only careful consideration of all factors can give the right answer to what the page size should be. For more information about choosing a page size, refer to Choosing a Page Size .
|
Chapter contents
Prev topic: Overview of Btrieve Features
|