> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corvic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Postgres Change Data Capture

> Keep a live copy of PostgreSQL tables in Corvic from your database's logical replication.

With change data capture (CDC), Corvic keeps a copy of each Postgres table you name. It copies each table once, then follows every committed insert, update, and delete through your database's logical replication. Changes reach Corvic within seconds of each commit and land in the table each time the pipeline runs.

Nothing is installed in your database. It needs logical replication switched on, a publication naming the tables, and a user with the replication attribute that Corvic can reach, directly, from [Dedicated IP](https://docs.corvic.ai/virtual-network/dedicated-ip.md) addresses, or over [Private Networking](https://docs.corvic.ai/virtual-network/private-networking.md).

## What your database needs

* **PostgreSQL 10 or later**, on a primary. A read replica can't hold a logical replication slot before Postgres 16.

* **`wal_level = logical`**, which takes a restart:

  | Where it runs | How to turn it on |
  | - | - |
  | Self-managed | `ALTER SYSTEM SET wal_level = logical;` then restart |
  | Amazon RDS / Aurora | Parameter group `rds.logical_replication = 1`, then reboot |
  | Google Cloud SQL | Database flag `cloudsql.logical_decoding = on` |
  | Azure Database for PostgreSQL (Flexible Server) | Server parameter `wal_level = logical` |

* **Room for one more replication slot and WAL sender** (`max_replication_slots`, `max_wal_senders`; both default to 10).

* **A replication login.** Corvic supplies `setup.sql`, which creates a `corvic_cdc` user with the `REPLICATION` attribute (on RDS and Aurora, `rds_replication`), grants it `SELECT` on the schema, and creates the publication. Run it with `psql` as a superuser, or as the tables' owner holding `CREATEROLE`.

## Connect it

**1. Add a PostgreSQL connector**

In [**Settings → Connector Vault**](https://app.corvic.ai/settings/vault), add a **PostgreSQL** database connector. Turn on **Replication login** and enter the `corvic_cdc` username and password. The same connector can also hold a reader login for ordinary SQL queries.

**2. Ask for the tables**

In a room, ask Corvic to replicate the tables you want, for example "keep a copy of `public.orders` and `public.customers`". Corvic sets up the watch and a pipeline that keeps them current.

Each row is keyed by the table's replica identity: its primary key, a unique index named with `REPLICA IDENTITY USING INDEX`, or every column under `REPLICA IDENTITY FULL`.

> [!NOTE]
>
> Corvic holds a logical replication slot on the database. While the slot exists, the database keeps the WAL it hasn't read. If you stop using CDC, ask Corvic to stop the watch so it drops the slot.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.