What is change data capture (CDC)?
Change data capture (CDC) is a pattern that identifies, captures, and streams changes made to a database in real time. It produces a chronological stream of INSERT, UPDATE, and DELETE events by reading the database's write-ahead log (WAL) — without impacting the performance of the source database.
How change data capture works
In PostgreSQL, CDC operates by reading the write-ahead log (WAL) using logical replication. The WAL is a sequential record of every change made to the database — it exists for crash recovery, but CDC repurposes it for change streaming.
A logical replication slot is created on the source database, and a decoder plugin (like wal2json or pgoutput) converts binary WAL entries into structured change events. Each event contains the operation type (INSERT/UPDATE/DELETE), the table name, the old and new row values, and a transaction timestamp.
CDC tools consume these events and deliver them to downstream systems: data warehouses, search indexes, caches, or — in Ardent's case — a change log for branch diffing.
Unlike database triggers, CDC reads from the WAL outside the database transaction. This means zero performance overhead on the source database — the WAL is already being written for crash recovery. CDC just reads it.
Ardent's CDC pipeline uses a custom extractor (based on pgstream) that captures both DML changes and DDL schema modifications via event triggers. This means Ardent tracks not just data changes but also schema changes like CREATE TABLE, ALTER COLUMN, and DROP INDEX.
Why change data capture matters
CDC is the foundation of modern data architecture. Without CDC, keeping systems in sync requires polling (expensive), dual writes (error-prone), or batch ETL (delayed). CDC provides real-time, reliable synchronization from a single source of truth.
For database branching, CDC solves a critical problem: knowing what changed. When an AI agent modifies 50 tables on a database branch, you need an audit trail before applying those changes to production. CDC captures every modification as it happens, enabling Ardent's diff feature.
Key players in the CDC space include Debezium (open source), Fivetran, and Confluent. Ardent uses CDC specifically for branch change tracking rather than general-purpose data replication.
change data capture in practice
-- CDC captures changes from the WAL
-- Example: Logical replication in PostgreSQL
-- 1. Create a logical replication slot
SELECT * FROM pg_create_logical_replication_slot(
'ardent_cdc_slot', 'wal2json'
);
-- 2. Make changes to the database
INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
UPDATE users SET name = 'Bob' WHERE id = 42;
DELETE FROM orders WHERE status = 'cancelled';
-- 3. CDC captures these as structured events:
-- { "kind": "insert", "table": "users",
-- "columnvalues": ["Alice", "alice@example.com"] }
-- { "kind": "update", "table": "users",
-- "oldkeys": {"id": 42},
-- "columnvalues": ["Bob"] }
-- { "kind": "delete", "table": "orders",
-- "oldkeys": {"status": "cancelled"} }
-- Ardent tracks changes automatically on every branch:
$ ardent branch diff
-- Shows every INSERT, UPDATE, DELETE across all tables
-- Row-level granularity — every changed row is capturedArdent's CDC pipeline runs automatically when a branch is created. Every modification — whether from an AI agent, a migration tool, or a manual query — is captured and stored. The ardent branch diff command reads this change log to show you exactly what happened on the branch.
Related terms
Frequently asked questions
What is change data capture (CDC)?
CDC tracks and streams database changes in real time by reading the write-ahead log. It captures INSERT, UPDATE, and DELETE events without impacting source database performance.
How does Ardent use CDC?
Ardent uses CDC to track every modification on a database branch, enabling the diff command. When an AI agent modifies data, CDC captures all changes for audit and review.
What's the difference between CDC and triggers?
Triggers run inside the database transaction and can impact performance. CDC reads from the WAL outside the transaction with zero overhead. CDC also captures changes from all sources including other triggers.
Try change data capture with Ardent
Create isolated database branches in under 6 seconds. No risk to production.