❖ PostgreSQL Page Representation |
Functions: src/backend/storage/page/*.c
Definitions: src/include/storage/bufpage.h
Each page is 8KB (default BLCKSZ
Also supports ~SQL-standard BLOBs (explicit large data items)
❖ PostgreSQL Page Representation (cont) |
Page-related data types:
// a Page is simply a pointer to start of buffer typedef Pointer Page; // indexes into the tuple directory typedef uint16 LocationIndex; // entries in tuple directory (line pointer array) typedef struct ItemIdData { unsigned lp_off:15, // tuple offset from start of page lp_flags:2, // unused,normal,redirect,dead lp_len:15; // length of tuple (bytes) } ItemIdData;
❖ PostgreSQL Page Representation (cont) |
Page-related data types: (cont)
include/storage/bufpage.h typedef struct PageHeaderData { XLogRecPtr pd_lsn; // xact log record for last change uint16 pd_tli; // xact log reference information uint16 pd_flags; // flag bits (e.g. free, full, ... LocationIndex pd_lower; // offset to start of free space LocationIndex pd_upper; // offset to end of free space LocationIndex pd_special; // offset to start of special space uint16 pd_pagesize_version; TransactionId pd_prune_xid;// is pruning useful in data page? ItemIdData pd_linp[]; // beginning of line pointer array, FLEXIBLE_ARRAY_MEMBER } PageHeaderData; typedef PageHeaderData *PageHeader;
❖ PostgreSQL Page Representation (cont) |
Operations on Page
void PageInit(Page page, Size pageSize, ...)
Page
pd_lower
pd_upper
OffsetNumber PageAddItem(Page page,
Item item, Size size, ...)
Page
void PageRepairFragmentation(Page page)
❖ PostgreSQL Page Representation (cont) |
PostgreSQL has two kinds of pages:
One important difference:
❖ TOAST'ing |
TOAST = The Oversized-Attribute Storage Technique
text
❖ TOAST'ing (cont) |
Large attribute values are stored out-of-line (i.e. in separate file)
Strategies for storing TOAST-able columns ...
PLAIN
EXTENDED
EXTERNAL
MAIN
Produced: 20 Feb 2023