Where do data pages come from?
<< Structure of a data page | Database technology articles | Firebird for the database expert: episode 1 - Indexes >>
Where do data pages come from?
By Ann Harrison
A Firebird database is an array of fixed-length pages in no particular order. How does the engine determine where a record should be stored?
Records are stored on data pages. When the engine prepares to store a record, it first compresses the record, then looks for a data page with available space.
- Often, when a table is active, there is a suitable page in cache, already allocated to the right table for the record, with space for the new record, and nothing special must be done.
- If not, the system first checks the current pointer page for the table, checks the array at the bottom to find the first page that isn't full, reads that page, and puts the record there.
- If the current pointer page doesn’t have a page with free space, the system checks subsequent pointer pages for data pages that can hold the new record.
- If a new page must be allocated,
- The engine finds the current page inventory page (PIP), looks on its header to find the first free page,
- If there are no free pages on the PIP, check the next PIP, until one has space, or the last one is found.
- If there is only one free page on the last PIP, use it to allocate another PIP.
- The system changes the state of the next bit on the PIP that represents a free page page.
- marks the PIP has having been changed.
- and formats a buffer to look like a data page.
- The engine finds the current page inventory page (PIP), looks on its header to find the first free page,
Once a page with sufficient space has been found, the engine locates a block of space for the record and an empty page index, if one is available, or creates a new page index. It then puts the lenght of the compressed record and its offset on the data page into the page index.
This paper was written by Ann Harrison and is copyright Ms. Harrison and IBPhoenix Inc. You may republish it verbatim, including this notation. You may update, correct, or expand the material, provided that you include a notation that the original work was produced by Ms. Harrison and IBPhoenix Inc.
See also:
Structure of a data page
back to top of page
<< Structure of a data page | Database technology articles | Firebird for the database expert: episode 1 - Indexes >>