Skip to content

Postgresql Performance Tuning Textbook

A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 103 companion flashcards using spaced repetition.

7 chapters · 103 cards · Updated

Chapters

  1. 1Diagnosing Slow Queries

    PostgreSQL performance tuning almost always starts with finding the right queries to fix. The canonical tool is the pg_stat_statements extension, which records normalized query tex...

  2. 2Indexing Strategies

    Indexes are usually the highest-leverage tuning tool in PostgreSQL. The default access method is B-tree, created simply with CREATE INDEX ON t (col), and it serves equality and ran...

  3. 3Statistics, VACUUM, and Table Health

    Two maintenance commands, ANALYZE and VACUUM, are central to keeping PostgreSQL fast. ANALYZE refreshes the row-count and distribution statistics that the planner relies on for cos...

  4. 4Concurrency, Locking, and Transactions

    PostgreSQL's concurrency model is MVCC, in which each row version carries the inserting transaction's xmin and the deleting transaction's xmax. A transaction's snapshot decides whi...

  5. 5Server Configuration and Connection Management

    A few settings carry most of the weight on a tuned PostgreSQL server. shared_buffers controls the database's own page cache, with a common starting point of about 25% of RAM on ded...

  6. 6Replication, Scaling, and Partitioning

    When a single server isn't enough, the first move is usually read scaling via streaming replication. A primary publishes its write-ahead log (WAL) to one or more replicas, which re...

  7. 7Schema Patterns, Migrations, and Extensions

    Many schema design choices have surprisingly large performance consequences. UUID primary keys of the v4 flavor are random and cause B-tree fragmentation because newly inserted row...

← Back to the Postgresql Performance Tuning deck