Skip to content
← All articles
Fundamentals·6 min read

What is Change Data Capture (CDC)?

An order changes from pending to shipped. The source database is correct, but the search index and analytics store will keep the old value until a data pipeline carries the change to them.

Change Data Capture (CDC) detects inserts, updates, and deletes and makes them available to downstream systems. Delivery can happen after a polling interval or within seconds of commit. The capture method determines the delay, available fields, and failure cases.


Why databases need a change path

Data rarely stays in one system. Order changes may feed analytics, search, inventory services, and a regional replica. Repeated full-table copies waste source work, while ordinary timestamp polling misses deletes and can lose updates around cursor boundaries.

CDC provides an incremental path. Depending on the source and method, a captured record can include the operation, source position, before and after values, and transaction metadata.

CDC is one use of transaction log processing. The transaction log processing overview also covers replication, audit, recovery, and replay.


Three common CDC methods

Timestamp polling

Timestamp polling adds an updated_at column, updates it on every write, and periodically queries for newer rows:

SELECT *
FROM orders
WHERE updated_at > '2026-06-10 14:00:00';

It uses ordinary query access and needs no replication privileges. A production implementation still needs:

  • A deleted row disappears before the next query unless the application uses soft deletes or a tombstone table.
  • Multiple updates between polls collapse into the last visible row state.
  • Every tracked write path must update the cursor column correctly.
  • A timestamp alone is not a safe cursor when rows share a value, commits arrive late, or the process crashes between reading and saving progress. A production design needs a stable tie-breaker and an overlap or replay policy.
  • Every poll adds query work to the source.
  • The result contains row state, not the source transaction boundary, unless the application stores that context separately.

Polling fits workloads with an explicit cursor, delete policy, and freshness target.

Database triggers

A row trigger can write each change into a changelog table that downstream consumers read. This PostgreSQL example assumes log_change_to_changelog() already exists; the trigger function and changelog schema are omitted:

CREATE TRIGGER capture_order_changes
AFTER INSERT OR UPDATE OR DELETE ON orders
FOR EACH ROW
EXECUTE FUNCTION log_change_to_changelog();

Triggers can capture inserts, updates, and deletes on every table where they are installed. They also add work to the source transaction.

  • Each source change writes another record and may update more indexes.
  • The trigger function and event schema must evolve with the source schema.
  • A row-level DML trigger does not capture schema changes. PostgreSQL provides separate event triggers for DDL; other engines have their own mechanisms.
  • Trigger syntax, execution order, privileges, and failure behavior vary by engine.

Trigger-based CDC can fit a database without a suitable log interface, provided the team accepts the write-path and maintenance cost.

Log-based capture

Log-based CDC reads a change interface derived from the database's transaction or replication log. It does not poll application tables or install a row trigger for each captured write. The source still needs the configuration and privileges required to expose logical changes.

Log-based CDC flow: a source change log feeds a CDC reader, which decodes records and delivers them to configured destinations

Remac uses this path for CDC.

  • A configured source can expose selected inserts, updates, deletes, and transaction markers. DDL coverage depends on the engine and decoder.
  • The reader uses the source log or change API instead of repeated table queries.
  • Source transaction identifiers can group related changes. Destination atomicity still depends on the sink and delivery protocol.
  • The path avoids an additional trigger write for every captured row, but still consumes source CPU, retained-log storage, network, and replication resources.
  • A healthy pipeline can deliver with low latency after commit. Actual delay depends on load, batching, network, destination behavior, and acknowledgment policy.

PostgreSQL CDC using pgoutput requires wal_level = logical, a logical replication slot, and a publication. MySQL row-level capture uses row-based binary logging. MongoDB change streams require a replica set or sharded cluster. Every source also needs a retention and resume policy.

Method comparison

Timestamp pollingDatabase triggersLog-based capture
DeletesRequires soft deletes or tombstonesCaptured when a delete trigger is installedCaptured when the source and decoder expose them
Transaction contextRequires application supportRequires custom changelog designAvailable when the source exposes it
Source costQuery work on each pollAdded transaction and changelog workDecoding, retention, network, and replication work
DelayPoll interval plus query timeTrigger write plus changelog consumptionPipeline and destination dependent
Source changesCursor column or equivalentTrigger functions and changelog tableLogical log or change-stream configuration
DDLRequires separate detectionRequires separate DDL/event triggersEngine and decoder dependent
Operating workScheduling and cursor correctnessTrigger and changelog maintenancePositions, retention, decoding, and delivery

A normalized log-based event

An order update may produce:

{
  "operation": "UPDATE",
  "database": "commerce",
  "schema": "public",
  "table": "orders",
  "position": "0/16B6A50",
  "timestamp": "2026-06-10T14:35:10Z",
  "transaction_id": "8842",
  "before": {
    "id": 1001,
    "status": "pending"
  },
  "after": {
    "id": 1001,
    "status": "shipped"
  }
}

The fields are illustrative. The source engine and configuration determine what is available. An insert has no previous row, while a delete has no new row.

For MySQL row-based logging, binlog_row_image = FULL records complete applicable before and after images. MINIMAL and NOBLOB omit some columns. In PostgreSQL, a complete old row requires REPLICA IDENTITY FULL; the default replica identity generally provides key information when an old tuple is needed.

Before and after values let consumers identify field transitions or compute differences. They do not make the event an immutable audit record. Audit systems still need retention, access control, integrity protection, and an identity model.


Where CDC is useful

Analytics feeds. Send selected transactional changes to an analytical store without rescanning complete source tables.

Search synchronization. Update or remove indexed documents after the corresponding source change.

Service data propagation. Let a service consume committed changes without synchronously querying the source service after every update. Teams still need an owned schema and failure policy.

Cache invalidation. Use a committed change to refresh or remove a cache entry. Delivery delay determines how long stale data can remain.

For the database logs behind log-based capture, see WAL, binlog, and oplog.

We built Remac as a database-agnostic transaction log processor. CDC is one logical-mode function. PostgreSQL is the first implemented source, with Kafka, RabbitMQ, Amazon S3, PostgreSQL, HTTP webhooks, files, and standard output available as destinations. MySQL, MongoDB, and Oracle sources are planned.


Further reading

More from this volume