Replication Basics — Complete Guide
Replication Basics — 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 39 of 100
Replication Basics
SQL → Advanced
SQL · 1 — Queries · ~6 min · PostgreSQL — Transactions & MVCC
What is this?
Replication copies data from primary to standby servers — physical (byte-for-byte WAL) or logical (row changes). Standbys can serve read-only queries or take over on failure.
Why should you care?
PostgresVerse production runs primary in Mumbai and standby in Hyderabad for disaster recovery and read scaling.
See it live — copy this example
Run in pgAdmin or psql.
-- On primary (read settings)
SHOW wal_level;
SELECT client_addr, state, sync_state
FROM pg_stat_replication;
What happened?
- wal_level replica enables physical streaming.
- pg_stat_replication lists connected standbys, replay state, and sync mode — empty until you configure replication.
Practice next
- Confirm wal_level is replica or logical on primary.
- Review postgresql.conf and pg_hba.conf replication entries (lab docs).
- Query pg_stat_replication after lab standby connects.
- List replication slots: SELECT * FROM pg_replication_slots;
- Check replay lag: now() - pg_last_xact_replay_timestamp() on standby.
Remember
WAL stream keeps standbys near real-time. Physical replication copies whole cluster. Logical replication copies selected tables.
PostgresVerse DR baseline
Startup configures one synchronous standby before RBI audit of payment data.
Outcome: RPO/RTO documented with measured replay lag under 1s.
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!