pgstats and PostgreSQL 18
summary
PostgreSQL moves cumulative stats into shared memory since v15 and v18 adds concrete changes: variable vs fixed-size stat kinds, 8-byte OIDs for object keys, backend-level APIs (pgstat_backend.c) and pgstat_io now counts bytes instead of blocks. Stats live in shared memory, flush on commit and are lost on crash unless saved at shutdown, which can leave autovacuum blind. v19 exposes an extension API so extensions can register custom stat kinds using provided templates and callbacks.
AI-written summary · about
chapters (12)
- 0:00Introduction and speaker intro
- 1:51PG stats architecture overview
- 4:17Stats kinds and shared memory
- 8:15Core stats implementation files
- 10:24Fixed size stats details
- 11:47Transaction commit and stats flushing
- 12:30Variable size stats and hash tables
- 14:12PostgreSQL 18 new APIs
- 15:38PG stat IO improvements in 18
- 16:20Parallel worker and statement stats
- 17:03Extensions using PG stats
- 18:47Future of PG stat statements
