Quick revision
The short answer
Physical streaming replication ships the raw WAL bytes, so the standby is a byte-for-byte copy of the whole cluster on the same major version, and it can only serve reads. Logical replication decodes the WAL into row changes for the tables in a publication and applies them on a subscriber that is an ordinary, writable database, which can even run a newer major version. That makes physical replication the tool for high availability and read replicas, and logical replication the tool for upgrades and sharing selected data.
What to remember
In this answer, we saw that both kinds of replication start from the WAL. Physical streaming replication ships the WAL bytes and produces a read-only, byte-identical copy of the whole cluster on the same major version, which is ideal for failover and read replicas. Logical replication decodes the WAL into row changes for chosen tables and applies them on a normal writable database that may run a newer version, which makes it the tool for upgrades and selective sharing, as long as we handle DDL and sequences ourselves. Both can use replication slots, and both can be made synchronous with synchronous_standby_names.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Physical streaming replication ships the raw WAL bytes, so the standby is a byte-for-byte copy of the whole cluster on the same major version, and it can only serve reads. Logical replication decodes the WAL into row changes for the tables in a publication and applies them on a subscriber that is an ordinary, writable database, which can even run a newer major version. That makes physical replication the tool for high availability and read replicas, and logical replication the tool for upgrades and sharing selected data.
Why this question is asked
Almost every production PostgreSQL setup uses replication, and both kinds are called replication, so the two are easy to mix up. The difference decides what we can do with the copy: fail over to it, query it, write to it, or upgrade through it. Interviewers ask this to check that we know what actually travels between the servers and what that implies. In this answer, we will recap the WAL, then look at what each kind copies, what the receiving side can do, the limits of logical replication, and how slots and synchronous commit fit both.
1A Quick Recap of the WAL
Every change in PostgreSQL is first written to the write-ahead log, the WAL, before the data pages themselves are changed on disk. The WAL is a stream of low-level records such as 'in block 4711 of this file, at offset 120, put these bytes'. After a crash, PostgreSQL replays the WAL to bring the data files back to a consistent state.
Both kinds of replication start from this same stream. They differ in what they do with it: physical replication sends the records as they are, and logical replication reads them, works out which rows changed, and sends those row changes instead.
2Physical Streaming Replication
In streaming replication, the standby connects to the primary and receives WAL records continuously, then replays them exactly as crash recovery would. The result is a byte-identical copy of the entire cluster: every database, every table, every index, the system catalogs, even the bloat. Because the bytes are the same, the standby must run the same major version, the same architecture, and compatible build settings.
With hot_standby on, which is the default, the standby accepts read-only queries while it replays. Any attempt to write fails with an error saying it cannot execute the statement in a read-only transaction. It cannot have its own tables or indexes either, because anything it held would be overwritten by the stream. When the primary fails, we promote the standby and it becomes the new primary.
3Logical Replication
Logical replication works at the level of rows. On the publisher we create a publication that names the tables to share. A process called a WAL sender decodes the WAL into changes such as 'insert this row into orders' or 'update the row with this primary key', and sends them to the subscriber. The subscriber is a normal PostgreSQL database with its own catalogs, so it applies the changes as ordinary inserts, updates and deletes.
Because the subscriber is independent, it can do things a standby never can. It can accept writes to other tables, have extra indexes or different ones, keep tables that the publisher does not have, and receive data from several publishers. And because row changes do not depend on the on-disk format, the subscriber can run a different major version, which is why logical replication is the standard way to upgrade with nearly no downtime.
| Question | Physical streaming | Logical |
|---|---|---|
| What travels | raw WAL bytes | decoded row changes |
| Scope | the whole cluster | chosen tables in a publication |
| Receiving side | read-only hot standby | normal writable database |
| Major versions | must be the same | can differ (used for upgrades) |
| DDL and sequences | copied, it is all bytes | not copied in most versions |
| Typical use | failover, read replicas | upgrades, data sharing, CDC |
Notice that the tables must already exist on the subscriber. That points to the main limits, covered next.
4What Logical Replication Does Not Copy
Logical replication sends row changes, and DDL is not a row change. If we add a column on the publisher, the subscriber does not get it, and as soon as rows arrive with the new column the apply worker fails until we add the column there too. So schema changes must be applied on both sides, usually subscriber first. Sequence values are also not copied in most versions, so a subscriber that is about to become the primary needs its sequences set before switchover. These points have been changing between releases, so check your version.
Logical replication also needs a way to identify rows for updates and deletes, normally the primary key, or a REPLICA IDENTITY setting for tables without one.
5Slots and Synchronous Commit in Both
Both kinds can use a replication slot, a record on the primary that remembers how far a consumer has read, so the primary keeps WAL until the consumer has it. Logical replication always uses one. A slot protects the consumer, but an abandoned slot keeps WAL forever, so slots need monitoring.
Both can also be synchronous. synchronous_standby_names lists the standbys whose confirmation a commit must wait for, and synchronous_commit decides how far they must have got. With on, the commit waits until the standby has flushed the WAL to disk. With remote_apply, it waits until the standby has also replayed it, so a query on that standby right after the commit sees the change.
6Follow-up questions
What does synchronous_commit = remote_apply guarantee?
It guarantees that when COMMIT returns, every synchronous standby named in synchronous_standby_names has not only written and flushed the WAL but also replayed it. So a read on that standby immediately afterwards sees the committed data, which gives read-your-writes across servers. The cost is that each commit waits for the slowest synchronous standby to apply, which adds latency, and if that standby stops responding, commits wait.
Can I use a physical standby for reporting with extra indexes?
No. The standby must be byte-identical, so it cannot have its own indexes or tables. If reporting needs different indexes, a logical subscriber is the right tool, because it is a normal database that receives the rows and can be indexed however we like.
Which one does a change data capture tool like Debezium use?
Logical decoding, the same machinery that logical replication uses. The connector creates a logical replication slot and reads row changes through an output plugin such as pgoutput.
7Conclusion
In this answer, we saw that both kinds of replication start from the WAL. Physical streaming replication ships the WAL bytes and produces a read-only, byte-identical copy of the whole cluster on the same major version, which is ideal for failover and read replicas. Logical replication decodes the WAL into row changes for chosen tables and applies them on a normal writable database that may run a newer version, which makes it the tool for upgrades and selective sharing, as long as we handle DDL and sequences ourselves. Both can use replication slots, and both can be made synchronous with synchronous_standby_names.
Open with
Both start from the WAL, but they ship different things. Streaming replication sends the WAL bytes themselves, and the standby replays them like crash recovery, so it is a byte-identical copy of the whole cluster: every database, the catalogs, everything.
Then, if they want more
That means the same major version, and the standby is read-only; with hot_standby it serves queries but cannot write or have its own indexes. It is what we use for failover and read replicas. Logical replication decodes the WAL into row changes for the tables in a publication, and the subscriber applies them as normal inserts, updates and deletes.
The subscriber is an ordinary writable database: it can have other tables, different indexes, and it can be on a newer major version, which is why we use it for upgrades and for sharing selected data.
The catch is that it does not replicate DDL or, in most versions, sequence values, so schema changes go to both sides and sequences have to be synced at switchover.
Both can use replication slots so the primary keeps WAL for the consumer, and both can be synchronous through synchronous_standby_names; with synchronous_commit set to remote_apply, the commit even waits until the standby has replayed the change, so a read there sees it.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- PostgreSQL 14, PostgreSQL 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Compare PostgreSQL physical streaming replication with logical replication. What does...": https://scrivio-interview-library.netlify.app/databases/postgresql/971f1b05cb/