+--------+----------+------------+---------------------------+ | Header | Pointers | Free space | Nodes | +--------+----------+------------+---------------------------+
Header: A BTREE page has the following metadata:
Size Description 4 Number of this page 4 Page number of preceding page 4 Page number of following page 3 Doc id of this page 1 Key type of this page 4 Reserved 4 bytes 4 Flags: 0x01 - BTree internal page 0x02 - BTree leaf page 0x04 - Overflow page 0x08 - Recno internal page 0x10 - Recno leaf page 0x20 - Never delete this chain of pages 2 Lower bound of free space on page 2 Upper bound of free space on page
Page number of preceding page: For internal/leaf page, it is used to store parent page number. For overflow page, it is used to store original page number. The parent page number of root page is 0.
Page number of following page: For leaf page, it is used to chain all leaf pages together. For internal page, it is used as the leftmost pointer to the pages less than key.
Pointers: A series of two-byte offsets indicating the location of successive nodes.
Nodes: For internal pages, each node contains a key and the page containing elements greater than or equal to that key (but smaller than the next key). For leaf pages, each node has a key and a data item. Ordinarily, the key and/or data immediately follow the flags. If the key or data is too big, it's stored on a separate 'overflow' page (or pageS, if it's really big!). In that case, the node contains a 4-byte page number and a 4-byte size instead of the corresponding key or data bytes.
Overflow pages have the same header as normal pages, but simply hold raw key/data bytes. They use the 'next page' value to chain successive pages of data together.
|
|
|
|