← Wed, Nov 4 digest

The Internals of PostgreSQL

read article ↗ hn thread ↗

A comprehensive guide to PostgreSQL internals covering architecture, query processing, concurrency control, and replication.

read it It is a highly regarded, long-standing resource for understanding the database kernel, frequently cited by engineers.

summary

The documentation provides a detailed breakdown of PostgreSQL's subsystems, including its process and memory architecture, buffer management, and write-ahead logging. It aims to give a complete picture of how the database functions internally to aid in administration and integration. The content is regularly updated to cover recent versions, including beta releases and specific features like asynchronous I/O.

key points

  1. Covers 12 chapters ranging from basic cluster architecture to advanced logical replication.
  2. Explains critical mechanisms like Heap Only Tuple (HOT) updates and Vacuum processing.
  3. Details the interaction between the buffer manager and Write-Ahead Logging (WAL) for durability.
  4. Includes specific guidance on concurrency control and streaming replication.

who should read it

Database engineers, backend developers, and SREs who need to optimize or extend PostgreSQL.

discussion warm

consensus

The resource is widely praised as invaluable for those working on the database kernel, with specific praise for the HOT update section.

pushback

Some debate exists regarding PostgreSQL's MVCC implementation and its reliance on vacuuming compared to block-undo systems like Oracle.

best comment by getbrew ↗

The HOT chapter is the one with the most direct practical payoff. Two things worth knowing from it: HOT only kicks in when no indexed column changes and the new tuple fits on the same page, so an index on a frequently-updated column (status, updated_at) quietly disables it for every update to that table. And lowering fillfactor (say 80-90) on update-heavy tables leaves free space on each page so HOT can actually happen. Comparing n_tup_hot_upd to n_tup_upd in pg_stat_user_tables is a cheap way to see whether you're getting HOT updates before tuning anything.

Provides actionable practical tips on how to use fillfactor and pg_stat_user_tables to optimize HOT updates.

Generated by an LLM from the article and thread. Check the sources before relying on it.