Purpose: Explore PostgreSQL’s specific implementation and design choices
Page Header (24 bytes)
Purpose: Fixed header containing page metadata
Content:
Information about page contents
Available free space tracking
Essential page management data
ItemIds (4 bytes each)
Function: Array of item pointers (not actual items/tuples)
Structure: Each ItemId = 4-byte offset:length pointer
Points To: Offset location and size of items within the page
HOT Optimization:
Enables Heap Only Tuple optimization
During updates, pointer redirects to new tuple location
Allows indexes to maintain references to old tuple ID
Very powerful for performance
Criticism:
At 4 bytes each, storage overhead can be significant
Example: an 8KB heap page holds at most ~291 tuples (MaxHeapTuplesPerPage) = ~1.2KB of line pointers; with small rows that’s still a big share of the page
Items (Variable length)
Content: Actual items/tuples stored sequentially
Layout: Items packed one after another
Terminology:
Row: What user sees
Tuple: Physical instance of row in page
Item: The tuple itself
MVCC Impact: Same row can have multiple tuples (active + historical + dead)
Special Section (Variable length)
Purpose: Index access-method-specific data
Applies To: Every page of every index type (B-tree, hash, GiST, GIN, SP-GiST, BRIN); for B-tree that means all pages (internal and leaf, plus the meta page). It is empty (size 0) on heap/table pages
Content: For B-tree, sibling links (previous/next page), the tree level and flags (leaf, root, deleted, etc.)
Function: Enables efficient B-tree traversal (e.g. range scans along the sibling links)
Tuple Referencing Example
Structure: Shows how tuples are referenced through ItemIds
Benefits: Indirection allows for optimizations like HOT
Summary
Key Concepts
Universal Storage: All database data ultimately stored in pages (indexes, sequences, tables)
Abstraction: Pages allow database to work uniformly regardless of content type
Structure: Pages contain headers and data, stored as files on disk
Flexibility: Each database implements different page layouts and storage methods
Common Principle: Consistent concept across all database systems despite implementation differences
Implementation Variations
Page Layout: Different databases use different internal page structures
Storage Methods: Various approaches to storing pages on disk
Optimization: Each system optimizes for different use cases and workloads
Standards: While concepts are universal, specific implementations vary significantly