InfraMaxx

Track

PostgreSQL & Databases lessons

41 short lessons on PostgreSQL & Databases. Each one starts from a real situation, shows how it works, and ends with a quiz. Free to read.

Start with the first lesson

All 41 lessons

  1. Relational databases: tables, SQL and indexesIntermediate · 5 min

    Why the same query over 3 million rows takes 412 milliseconds and only 0.06 ms with one extra line, and the four ideas you need before anyone says RDS to you.

  2. Tuple visibilityBeginner · 4 min

    PostgreSQL MVCC lets transactions see row versions according to snapshots and isolation semantics. Updates create new row versions; VACUUM eventually reclaims obsolete…

  3. Isolation levelsBeginner · 4 min

    READ COMMITTED takes a fresh snapshot per statement; REPEATABLE READ retains a stable snapshot for the transaction.

  4. Row locksBeginner · 4 min

    UPDATE acquires row-level locks and concurrent writers can wait behind the transaction.

  5. DeadlocksBeginner · 4 min

    PostgreSQL detects deadlock cycles and aborts one transaction to break the cycle.

  6. B-tree index selectivityBeginner · 4 min

    The planner compares index access cost against a sequential scan using table statistics.

  7. EXPLAIN ANALYZEBeginner · 4 min

    EXPLAIN (ANALYZE, BUFFERS) runs the query and reports actual plan timing and buffer usage.

  8. HOT updatesBeginner · 4 min

    Heap-only tuple updates can avoid secondary index churn when indexed columns stay unchanged and room exists on the page.

  9. Partial indexesBeginner · 4 min

    Partial indexes contain rows matching their predicate and can shrink a hot query access path.

  10. Write-ahead logBeginner · 4 min

    WAL records changes before durable data pages are written, enabling crash recovery and replication.

  11. CheckpointsBeginner · 4 min

    Checkpoints bound crash recovery work by writing dirty buffers to storage.

  12. Logical replicationBeginner · 4 min

    A publication emits selected table changes and a subscription applies them on the receiver.

  13. Replication lagBeginner · 4 min

    Replication delay can arise from network transport, WAL replay, or apply throughput.

  14. AutovacuumBeginner · 4 min

    Autovacuum reclaims reusable space and advances transaction ID freeze horizons.

  15. pg_stat_statementsBeginner · 4 min

    The extension aggregates normalized query execution statistics across calls.

  16. Connection poolingIntermediate · 5 min

    Why 800 mostly idle connections can take down a database that is doing almost nothing, and the one setting in PgBouncer that decides what your application can still do…

  17. MVCC visibilityBeginner · 4 min

    PostgreSQL keeps several versions of a row, so readers and writers rarely block each other. You learn how a snapshot decides which version a query sees, and why old…

  18. Tuple versionsIntermediate · 4 min

    A tuple is one stored row version, with xmin and xmax in its header. You learn why a deleted row still takes space, and why a normal vacuum rarely shrinks the file.

  19. Vacuum and autovacuumIntermediate · 4 min

    PostgreSQL vacuum reclaims removable row versions and supports transaction-ID safety.

  20. Transaction ID wraparoundIntermediate · 4 min

    Transaction IDs are 32 bits and wrap, so PostgreSQL freezes old rows with VACUUM. You learn how to read the age of each database and table, and what blocks freezing.

  21. Isolation anomaliesIntermediate · 4 min

    An isolation level decides which concurrent changes a transaction can see, and which anomalies remain. You learn the four classic anomalies and how PostgreSQL's three…

  22. Deadlock detectionIntermediate · 4 min

    A deadlock is a cycle of lock waits, and PostgreSQL aborts one transaction in the cycle after deadlock_timeout. You learn how to find the blocker, and how lock ordering…

  23. B tree indexesIntermediate · 4 min

    A B-tree is the default index type, a sorted tree that serves equality, ranges and ordering. You learn how to test an index with EXPLAIN ANALYZE and check whether it is…

  24. Composite index orderingIntermediate · 4 min

    A composite index sorts by its first column, then by its second, so column order decides which queries it helps. You learn to order columns from the queries that…

  25. Index only scansIntermediate · 4 min

    An index-only scan answers from the index, but it still visits the heap for pages the visibility map has not marked all-visible. You learn to read Heap Fetches, and…

  26. EXPLAIN ANALYZE BUFFERSAdvanced · 4 min

    EXPLAIN ANALYZE with BUFFERS shows how many pages each plan node reads from cache and from outside it. You learn to read the hit, read and temp counts before judging a…

  27. Planner statisticsAdvanced · 4 min

    Planner statistics are sampled estimates that ANALYZE stores per column, and the planner uses them to pick plans. You learn to compare estimates with real counts and to…

  28. WAL fundamentalsAdvanced · 4 min

    WAL records each change before the data page is written, so a crash is repaired by replaying the log. You learn why a commit waits for the log flush, and why fsync must…

  29. Replication slotsAdvanced · 4 min

    A replication slot makes the primary keep WAL until a consumer has received it. You learn how an inactive slot fills the disk, and how to measure it and drop it safely.

  30. Streaming replicasAdvanced · 4 min

    A streaming replica replays WAL from the primary and can serve read-only queries, but it trails the primary and can cancel queries. You learn to check lag and conflicts…

  31. PITR with pgBackRestAdvanced · 5 min

    Point-in-time recovery rebuilds a database to a chosen moment from a base backup and archived WAL. A restore is only as good as the archive that covers the target time.

  32. PgBouncer transaction poolingAdvanced · 5 min

    PgBouncer transaction pooling lends a server connection for one transaction at a time. Session state set outside a transaction can leak to other clients, so the…

  33. Partition pruningAdvanced · 4 min

    Partition pruning lets the planner skip child tables whose bounds cannot match a query's WHERE clause. The filter must compare the partition key directly, or the…

  34. Schema migration safetyAdvanced · 5 min

    Many ALTER TABLE forms take a strong lock that blocks reads and writes while they wait. Safe migrations set lock timeouts, check for open transactions, and build…

  35. Composite index ordering: operational verificationAdvanced · 5 min

    A composite B-tree index is sorted by its leading column first, so queries that constrain the leading columns use it best. Column order also decides whether a sort can…

  36. Partial indexes: failure analysisAdvanced · 5 min

    A partial index covers only rows that match its predicate. The planner uses it only when it can prove the query's condition implies that predicate, which is often lost…

  37. Index only scans: operational verificationAdvanced · 5 min

    An index-only scan answers a query from the index, but it still reads table pages that the visibility map does not mark as all-visible. Heap fetches show how much table…

  38. EXPLAIN ANALYZE BUFFERS: failure analysisAdvanced · 5 min

    EXPLAIN ANALYZE with BUFFERS shows the blocks each plan node read from shared buffers or the operating system. Those counts explain slow runs that the plan text alone…

  39. Planner statistics: operational verificationAdvanced · 5 min

    The planner chooses plans from row estimates that come from statistics collected by ANALYZE. A bulk load leaves those statistics stale until the table is analyzed again.

  40. HOT updates: failure analysisAdvanced · 5 min

    A HOT update writes the new row version on the same page without new index entries, but only when no indexed column changes. Indexing a column that changes on every…

  41. WAL fundamentals: operational verificationAdvanced · 5 min

    Write-ahead logging writes each change to the log before the data page changes. The log is the basis of crash recovery, replication and archiving, so its volume follows…