Chapter 29. ページファイル

Table of Contents
ページ構造
ファイル
バグ情報

A description of the database file default page format.

データベースファイルのデフォルトのページ形式の説明。

This section provides an overview of the page format used by Postgres classes. User-defined access methods need not use this page format.

この節では、Postgres クラスで使われる ページ形式の概略を説明します。ユーザ定義のアクセスメソッドはこの ページ形式を使う必要はありません。

In the following explanation, a byte is assumed to contain 8 bits. In addition, the term item refers to data which is stored in Postgres classes.

以降の説明では、バイト を 8 bit 長としていま す。更に、アイテム という用語は Postgres クラス内に保存されているデータ を示します。

ページ構造

The following table shows how pages in both normal Postgres classes and Postgres index classes (e.g., a B-tree index) are structured.

以下の表は、通常の Postgres クラスと (B-tree インデックスといった) Postgres インデックスクラスの両方で使われるページがどの様な構造を持っているのか を示します。

Table 29-1. ページレイアウトの例

アイテム説明
itemPointerData
詰め物
itemData...
未割当領域
ItemContinuationData
特別領域
``ItemData 2''
``ItemData 1''
ItemIdData
PageHeaderData

The first 8 bytes of each page consists of a page header (PageHeaderData). Within the header, the first three 2-byte integer fields (lower, upper, and special) represent byte offsets to the start of unallocated space, to the end of unallocated space, and to the start of special space. Special space is a region at the end of the page which is allocated at page initialization time and which contains information specific to an access method. The last 2 bytes of the page header, opaque, encode the page size and information on the internal fragmentation of the page. Page size is stored in each page because frames in the buffer pool may be subdivided into equal sized pages on a frame by frame basis within a class. The internal fragmentation information is used to aid in determining when page reorganization should occur.

各ページの最初の 8 バイトでページヘッダ( PageHeaderData )を構成し ます。ヘッダの中で最初の 3 つの 2 バイト整数のフィールド( lowerupperspecial )はそれぞれ、未割当領域の開始点、そ の終了点、特別領域 の開始点へのバイト単位で のオフセットを表します。特別領域はページの終りにある領域で、ページ を初期化する際に割り当てられ、アクセスメソッド固有の情報を持ちます。 ページヘッダの残る 2 バイトは opaque で、ペ ージサイズとページの内部的な断片化に関する情報をコード化しています。 ページサイズは各ページ毎に保存されています。バッファプール内のフレ ームは、クラスの持つフレーム原理によって、1 つのフレームに対して同 じ大きさのページに分割される可能性があるからです。内部的な断片化情 報は、ページ再構成をいつ行なうべきかを決定することを援助するために 使用されます。

Following the page header are item identifiers (ItemIdData). New item identifiers are allocated from the first four bytes of unallocated space. Because an item identifier is never moved until it is freed, its index may be used to indicate the location of an item on a page. In fact, every pointer to an item (ItemPointer) created by Postgres consists of a frame number and an index of an item identifier. An item identifier contains a byte-offset to the start of an item, its length in bytes, and a set of attribute bits which affect its interpretation.

ページヘッダの後には、アイテム識別子( ItemIdData )があります。新規アイテム識別子は、 未割当領域の最初の 4 バイトに割り当てられます。アイテム識別子は、開放 されるまで移動することがありませんので、そのインデックスはページ上のア イテムの場所を示すことにも使用できます。実際、 Postgres によって作られたアイテム( ItemPointer )を示すポインタは全てフレーム番号 とアイテム識別子から構成されています。アイテム識別子は、アイテムの開始 点へのバイト単位のオフセット、アイテムのバイト長、及び、アイテムの解釈 に影響を与える属性ビットの集合から構成されます。

The items themselves are stored in space allocated backwards from the end of unallocated space. Usually, the items are not interpreted. However when the item is too long to be placed on a single page or when fragmentation of the item is desired, the item is divided and each piece is handled as distinct items in the following manner. The first through the next to last piece are placed in an item continuation structure (ItemContinuationData). This structure contains itemPointerData which points to the next piece and the piece itself. The last piece is handled normally.

アイテム自体も未割当領域の終りから逆向きに割り当てられた領域に保存され ます。通常、アイテムは解釈されません。しかし、アイテムが 1 つのページ にしまうには大き過ぎる場合や、アイテムの断片化が望まれる場合には、アイ テムは分割され、各要素は限定されたアイテムとして、以下の方法で取り扱わ れます。要素の 1 番目から最後から 2 番目までは、継続アイテム構造体( ItemContinuationData )内に保存されます。この構 造体には、次の要素と要素自身を示す itemPointerData が含まれます。最後の 要素は通常通りに扱われます。