Data platform · PostgreSQL replication
PostgreSQL replication: built-in options, their limits, and when a CDC tool helps
PostgreSQL replication keeps a second copy of your data current as the first one changes. PostgreSQL ships two built-in ways to do it: streaming replication for a standby that can take over, and logical replication for chosen tables. Both are sound, and both have limits that only show up in production. Interkey designs PostgreSQL replication from Riyadh, and uses iblync, its own replication platform, where the built-in options stop.
PostgreSQL replication at a glance
| Question | Short answer |
|---|---|
| What it is for | High availability, read copies for reporting, disaster recovery copies, and moving data during a migration |
| Built-in options | Streaming (physical) replication of the whole cluster, and logical replication of chosen tables |
| Where logical replication stops | Schema changes, sequences, tables without a key, non-PostgreSQL targets, and slots that hold write-ahead log |
| When an external tool helps | A target that is not PostgreSQL, mapping or filtering, throttling, queueing, two-way sync and validation |
| Where it runs | The standby, the replica and the replication tooling can run on infrastructure inside the Kingdom |
| How it is priced | Per engagement after an assessment; iblync by quotation, per source system, target system and data volume |
For an executive: most PostgreSQL estates need nothing beyond the built-in replication, run and monitored properly. The assessment says which parts do, and why.
What PostgreSQL replication has to cover
Before choosing a method, write down what the copy is for. The answer changes the design more than any setting does.
Read more
- High availability. A standby that takes over when the primary fails, with a known amount of data that may be lost and a known time to switch.
- Read copies. Reporting and analytics moved off the primary, where some delay is accepted.
- Disaster recovery. A copy at a second site. Replication spreads a mistaken delete to the copy as fast as a good change, so it does not replace backups; our disaster recovery page covers the rest.
- Feeding another system. Selected tables sent to a data warehouse, a search index or a different database engine.
- Migration. A new server, a new major version or a new platform kept in step until cutover, as on our PostgreSQL migration page.
Relateddisaster recovery page
Streaming, logical, or an external CDC tool
| Point | Streaming replication | Logical replication | External CDC tool such as iblync |
|---|---|---|---|
| What is copied | The whole cluster, block for block | Chosen tables, as row changes | Chosen tables, as row changes, with mapping |
| Target | PostgreSQL, same major version | PostgreSQL | PostgreSQL or another engine on the tool's connector list |
| Target writable | No, read-only until promoted | Yes | Yes, and two-way sync where agreed |
| Schema changes | Copied automatically | Not copied; applied by hand on both sides | Handled by the tool's mapping rules, agreed per project |
| Best fit | High availability and a standby for failover | Reporting copies, consolidation, version upgrades | Different engines, transformation, migration bridges |
| Main thing to watch | Lag, failover handling, and the standby's own load | Slots holding write-ahead log, conflicts that stop the apply | Lag, queues, and the agreed validation checks |
The columns are not rivals: many estates run streaming replication for availability and a logical or external feed for reporting at the same time.
Streaming replication and PostgreSQL high availability
Streaming replication sends the primary's write-ahead log (WAL) to one or more standby servers, which replay it. The standby is an exact copy of the whole cluster and can serve read-only queries. It is the usual basis of PostgreSQL high availability.
The decisions that matter are few. Asynchronous replication keeps the primary fast but can lose the last few transactions on failover; synchronous replication waits for a standby to confirm, which protects those transactions and adds delay to every commit. PostgreSQL itself does not decide when to fail over: a failover manager, or a person following a written runbook, promotes the standby and moves the applications. Without that piece, a standby is a copy, not availability.
Read more
Streaming replication needs the same major version on both sides, so it cannot carry an upgrade or a move to another engine. Long reports on a standby can also clash with changes being replayed, and the settings that control this trade query cancellations against replay delay.
Postgres logical replication: what it does and where it stops
Logical replication publishes row changes from chosen tables (a publication) to another PostgreSQL database that subscribes to them. It needs wal_level set to logical, which takes a restart. It works across major versions and the subscriber stays writable, so it suits reporting copies, consolidation and upgrades. Its limits are known, and worth listing before production finds them:
Read more
- Schema changes are not copied. A new column added on the publisher is not added on the subscriber; every DDL change is applied on both sides, in the right order.
- Sequences. Depending on the version, sequence values are not replicated, so they are set by hand before a subscriber takes writes.
- Keys. Updates and deletes need a primary key or a declared replica identity on each table; tables without one need a decision.
- Slots hold the log. A replication slot keeps WAL until the subscriber confirms it. A subscriber that is away for a weekend can fill the primary's disk unless a limit is set and watched.
- Conflicts stop the apply. If an incoming row breaks a constraint on the subscriber, replication stops at that change until someone fixes it.
- Failover. Depending on the version, a logical slot may not carry over to a promoted standby, so subscribers need a plan for the day the primary fails.
- PostgreSQL only. Publication and subscription connect PostgreSQL to PostgreSQL. Feeding another engine means reading changes through logical decoding with a separate tool.
Postgres CDC with iblync: when an external tool helps
Change data capture (CDC) reads the changes a database makes and applies them elsewhere; our change data capture page compares the capture methods. iblync is Interkey's own data migration and replication platform, and PostgreSQL is on its published connector list. It helps where the built-in options stop:
- A different target. Changes from PostgreSQL can be applied to another engine on iblync's connector list, with type and field mapping agreed per project.
- Throttling and queueing. Replication is throttled so production keeps its capacity, and if the target is unavailable, changes queue instead of failing and are applied on recovery.
- Two-way sync. iblync supports bi-directional synchronisation for a transition in which two systems both take writes; our bidirectional sync page covers the conflict rules this needs.
- Proof. iblync's own site states that validation uses checksums and row counts. The pass conditions for your data are agreed before anyone relies on the copy.
Read more
Where it does not fit: iblync is not a failover manager and does not replace a streaming standby for high availability, and for a PostgreSQL-to-PostgreSQL reporting copy, built-in logical replication run well is often enough. The assessment checks the source's logging settings, which decide how changes are read. More on the streaming itself is on our real time replication page.
Relatedchange data capture pageiblyncbidirectional sync pagereal time replication page
Where we see PostgreSQL replication used
- A standby in a second data hall, with a written and rehearsed promotion runbook.
- A reporting copy fed by logical replication, so month-end reports stop slowing the application.
- A major-version upgrade in which the new cluster subscribes to the old one and the switch takes minutes, not a long dump and restore.
- A feed into another platform through CDC, with mapping and validation, while PostgreSQL stays the system of record.
Estates that run several engines tend to ask the same questions of each; our pages on MySQL replication and SQL Server replication cover those sources.
How a PostgreSQL replication project runs
-
Assessment.
Versions, cluster layout, tables and keys, change rate at peak, WAL settings, the purpose of each copy, the accepted lag and data loss, and residency. The output is a design, which may be built-in replication alone.
-
Design.
Streaming, logical, CDC or a mix; synchronous or asynchronous; where each copy runs; how failover and schema changes are handled.
-
Build and initial copy.
Standbys, publications or iblync connectors set up, and the first copy made without starving production.
-
Monitoring.
Lag, slot growth, queue depth and apply errors measured, with alerts that reach a person.
-
Rehearsal.
Failover, slot recovery and a schema change are rehearsed before go-live, and the runbooks updated.
-
Handover.
To your DBAs, with the runbooks, or ongoing support from Interkey.
What Interkey delivers in Saudi Arabia
One team for the assessment, design, build, monitoring and rehearsals, with support from Riyadh in Arabic and English. The standby, the replica and the replication tooling can run on infrastructure inside the Kingdom, which matters when the data is personal or regulated; where each copy may live is settled before any copy is made. If replication lag is already a worry on a running estate, our PostgreSQL monitoring page covers how to watch it.
What drives the cost
Quotes are per engagement, after the assessment. The drivers are the number of clusters and copies, the change rate, whether a copy must be synchronous, how many tables lack keys, how often the schema changes, whether the target is another engine, the deployment model, and who runs replication afterwards. iblync itself is priced by quotation, per source system, target system and data volume.
Questions buyers ask
Is PostgreSQL's built-in logical replication enough, or do we need a separate replication tool?
For a PostgreSQL-to-PostgreSQL copy with stable schemas, the built-in feature is often enough if slots and conflicts are monitored. A separate tool earns its place when the target is another engine, data must be mapped, or two systems both take writes.
Does PostgreSQL logical replication carry schema changes and sequence values to the subscriber?
Schema changes, no: each one is applied on both sides. Sequence values, depending on the version, are not replicated either, so they are set before the subscriber takes writes.
Which gives us PostgreSQL high availability: streaming or logical replication?
Streaming replication, with a failover manager or a rehearsed runbook to promote the standby. Logical replication is for chosen tables and copies that stay writable, not for failover.
Can changes from our PostgreSQL database be replicated into a different database engine?
Yes, through change data capture. iblync lists PostgreSQL among its connectors and applies the changes to other engines on its list, with mapping and validation agreed per project.
How is a PostgreSQL replication project priced in Saudi Arabia, and how long does it take?
Per engagement, after an assessment; iblync is quoted per source system, target system and data volume. The duration is given as a range after the assessment, driven by the number of copies, change rate and schema work.
Can the standby and the replication servers be hosted in a data centre inside the Kingdom?
Yes. The standby, the replica and the replication tooling can run on infrastructure inside the Kingdom. Where each copy lives, and who may reach it, is agreed before the first copy.
Next
Related pages
Next step
Review your PostgreSQL replication design
Tell us the PostgreSQL versions and clusters, what each copy is for, the rough change rate, any non-PostgreSQL targets, and the data loss and switch time you can accept.
Or directly
+966-11-2180999 [email protected]Tawuniya Towers, North Tower, 7th Floor, King Fahad Highway, Olaya, P.O. Box 56835, Riyadh 11564, Saudi Arabia