AWSM FSM! Free Space Maps Decoded
summary
Postgres stores free-space as a persistent per-relation FSM fork introduced in 8.4, using a binary-tree of pages where one FSM leaf covers ~2k heap pages (~16 MB) and two levels scale to ~32 GB; entries use 256 categories (32-byte granularity) stored in one byte with internal nodes bubbling up the max, so lookups are O(log n) and durable across restarts. Vacuum populates the FSM (it’s created lazily), the FP next slot spreads concurrent inserts to avoid hotspots, and the contrib tool pg_freespacemap lets you inspect results.
AI-written summary · about
chapters (22)
- 0:00Introduction and agenda
- 2:40What is an FSM
- 5:18MVCC refresher
- 8:57MVCC space issues
- 9:39FSM purpose and basics
- 13:17FSM and MVCC lifecycle
- 15:06FSM evolution in PostgreSQL
- 19:46FSM rewrite in PostgreSQL 8.4
- 22:19FSM forks and file structure
- 25:11FSM page layout and categories
- 27:16Binary tree structure in FSM
- 28:44Multi-level FSM trees
- 31:17FSM file creation demo
- 32:41Inspecting FSM contents
- 33:23FSM updates from vacuum
- 34:50Insert operations and FSM
- 36:40FSM as a hint structure
- 38:27FSM optimizations
- 39:56FP next slot concurrency
- 40:58FSM in other databases
- 41:40FSM extensions and parameters
- 42:43Future enhancements for FSM
related talks
33mFinding and fixing a data-corruption bug...
47mImproved Freezing in Postgres Vacuum: From Idea to Commit
54mReducing Costs and Improving Performance With Data Modeling in Postgres
50mInside PostgreSQL Shared Memory
39mPostgreSQL: Page Buffer Overview
45mEnhancing PostgreSQL Plasticity: New Frontiers in Memory Management
50mPostgreSQL meets ART - Using Adaptive Radix Tree to speed up vacuuming
34mIn core compression-How to shrink your database
