Change data capture
Copying every insert, update and delete from a database to other systems as it happens.
Change data capture, or CDC, is a technique for detecting each change made to a database and sending it elsewhere, almost in real time. Instead of copying a whole table every night, CDC sends only what changed: a new order inserted, a price updated, a customer deleted, each as a small event.
The most common method reads the database's own transaction log. Databases like PostgreSQL and MySQL already write every change to a log before applying it, for crash recovery and replication. A CDC tool such as Debezium or AWS Database Migration Service tails that log and turns each entry into an event, usually published to a stream. Older approaches use triggers or poll for rows with a recent updated_at, but they add load and can miss deletes.
CDC is how a data warehouse stays minutes behind the production database instead of a day, how a search index or a cache stays in sync with the source of truth, and how a database can be migrated with almost no downtime. The tricky parts are order, since events must be applied in the sequence they happened, schema changes in the source, and the first full copy that has to be taken before streaming changes on top of it.
Keep in mind
- Sends each insert, update and delete as an event, not whole tables.
- Usually reads the database's transaction log, so it adds little load.
- Keeps warehouses, caches and search indexes close to real time.
- Order, schema changes and the initial full copy need care.
Go deeper
- What is change data capture? (AWS)
- Debezium (open-source CDC platform)
- Change data capture on Wikipedia