Hot Standby — Complete Guide
Hot Standby — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of PostgreSQL Tutorial on Toolliyo Academy.
On this page
PostgreSQL Tutorial · Lesson 63 of 100
Hot Standby
SQL ✓ → Advanced
Advanced · 2 — Production · ~10 min · PostgreSQL — Replication & High Availability
What is this?
Hot standby is PostgreSQL read-only mode on physical replica — recovery applies WAL while accepting SELECT queries. hot_standby GUC enables concurrent reads during replay.
Why should you care?
PostgresVerse analytics team runs heavy SELECT on standby so BI queries do not steal I/O from checkout primary.
See it live — copy this example
Run in pgAdmin or psql.
-- On standby server
SHOW hot_standby;
SELECT pg_is_in_recovery();
SELECT count(*) FROM orders
WHERE created_at >= current_date;
What happened?
- pg_is_in_recovery() true confirms standby.
- hot_standby on allows SELECT while WAL replays.
- Long queries can conflict with replay — max_standby_streaming_delay applies.
Practice next
- Connect to standby not primary.
- Verify pg_is_in_recovery true.
- Run read-only report query.
- SET default_transaction_read_only = on on primary session to simulate read-only behavior.
- Query pg_stat_database_conflicts on standby.
Remember
Physical replica + hot_standby = read scale + DR. Writes always on primary unless promoted. Watch replay conflicts in pg_stat_database conflicts.
PostgresVerse BI offload
Metabase connected to standby; exec dashboards stop slowing OLTP.
Outcome: Primary buffer cache dedicated to checkout queries.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!