Skip to main content

Logical replication

Logical replication is native Postgres replication that streams row-level changes between a Lakebase database and another Postgres database. Lakebase can act as a subscriber that receives changes from an external publisher, or as a publisher that sends changes to an external subscriber.

Use logical replication to migrate an existing Postgres database into Lakebase, to replicate between Lakebase databases, or to stream changes from Lakebase to an external Postgres database.

Get started​

To replicate a single table end to end and see how the pieces fit together, start with the quickstart. It takes a few minutes and does not require an external database.

Use cases​

Use case

What it does

Guide

Migrate a Postgres database into Lakebase

Lakebase subscribes to an external Postgres publisher and copies its data in, then keeps it current until you cut over.

Replicate data into Lakebase

Replicate between Lakebase databases

Keep a second Lakebase database in sync for cross-region reads or a version upgrade.

Quickstart: Replicate between Lakebase databases

Stream changes to an external Postgres

Lakebase publishes changes to an external Postgres subscriber.

Replicate data from Lakebase

Use case

What it does

Guide

Migrate a Postgres database into Lakebase

Lakebase subscribes to an external Postgres publisher and copies its data in, then keeps it current until you cut over.

Replicate data into Lakebase

Replicate between Lakebase databases

Keep a second Lakebase database in sync for cross-region reads or a version upgrade.

Quickstart: Replicate between Lakebase databases

Stream changes to an external Postgres

Lakebase publishes changes to an external Postgres subscriber.

Replicate data from Lakebase

How logical replication works​

A publisher defines a publication, the set of tables whose changes it sends. A subscriber creates a subscription that connects to the publisher, copies the existing data, and then applies each insert, update, and delete as it happens. Which database connects to which determines the network direction:

The two logical replication directions. Lakebase as subscriber: an external Postgres publisher sends changes to Lakebase, which dials out to the publisher. Lakebase as publisher: Lakebase publishes changes and an external Postgres subscriber dials in to receive them.

Logical replication and other data movement methods​

Logical replication moves data between Postgres databases. To move Postgres changes into the lakehouse instead, use Lakebase Change Data Feed, which writes changes to a Unity Catalog managed Delta table. For a full comparison of the ways to move data in and out of Lakebase, see Move data in and out of Lakebase.

Limitations​

  • Logical replication is available on AWS and Azure.
  • Logical replication runs over public networking. Private Link is not supported for either direction. The subscriber connection is governed by the account network policy's allowed internet destinations, and the publisher connection is governed by the workspace IP access list.
  • Replication runs on the primary compute, not on read replicas.
  • Logical replication copies data, not schema. Create target tables before you start replication. Later schema changes are not replicated.
  • Foreign tables are not replicated.

Next steps​