What happens when the database your AI assistant relies on changes at 9:00 a.m., but the assistant is still answering questions with last night’s data? That gap is one of the quietest and most expensive problems in production AI. Change data capture (CDC) is the plumbing that closes it. (Separating tenant data in an enterprise assistant)
What Change Data Capture Actually Does
CDC is a set of techniques for spotting row-level changes in a database (inserts, updates, deletes) and shipping them to other systems as a stream of events. It is not a new idea and it is not AI-specific. Data engineers have used it for years to keep warehouses, search indexes, and caches in sync with operational databases.
The new pressure comes from AI. A retrieval pipeline, a feature store, or a fine-tuning job cannot rely on a single data load. It needs the right data, now, without a nightly rebuild that takes hours and hammers the source system.
There are two broad families of CDC:
| Approach | How it works | Trade-offs |
|---|---|---|
| Query-based (polling) | Runs periodic queries against a timestamp or version column | Simple to set up; adds load to the source; misses hard deletes; can miss changes between polls |
| Log-based | Reads the database’s transaction log and emits each committed change | Low latency and low overhead; captures deletes; requires log access and careful setup |
Most serious pipelines today lean on log-based capture. PostgreSQL’s logical replication, available since version 9.4, is a common foundation, and the official PostgreSQL logical replication documentation explains how decoding the write-ahead log produces a change stream. MySQL’s binary log plays a similar role. The appeal is straightforward: the database already writes every change to its log for crash recovery, so reading that log costs far less than repeatedly scanning tables. (Debezium documentation overview)
Why AI Systems Care So Much About Freshness

Traditional analytics tolerates a day-old warehouse. AI systems mostly do not.
Consider retrieval-augmented generation, the pattern introduced in the 2020 paper on retrieval-augmented generation for knowledge-intensive NLP tasks, where a model fetches relevant documents at query time and grounds its answer in them. If a policy document is updated and the retrieval index is not, the model confidently cites the old version. Users notice. Support tickets follow.
Feature stores have the same problem in a different shape. A feature store serves the same computed values to training jobs and to live inference so the model sees consistent inputs. When features are batch-loaded overnight, a customer’s behavior from this morning is invisible at inference time, and the model’s inputs drift from what it learned on. Streaming ingestion through CDC is one of the standard ways teams shrink that training-serving skew.
The practical consequences show up in three places:
- Vector indexes and search backends need incremental updates rather than full re-embedding runs.
- Feature stores need near-real-time values for inference.
- Evaluation and training datasets need to reflect what actually happened, including corrections and deletions.
The Core Architecture
A typical CDC pipeline for AI looks like this in practice. A source database commits a change. A capture tool reads the log and turns the change into an event. A messaging layer buffers and orders those events. One or more consumers apply them: an embedding worker that re-chunks and re-embeds updated documents, a feature computation job, an audit log, or a cache invalidator.
Debezium is the most widely used open-source capture layer. It runs on Apache Kafka Connect, the framework for scalable, fault-tolerant source and sink connectors described in the Apache Kafka Connect documentation, and it publishes changes from databases such as PostgreSQL, MySQL, MongoDB, Oracle, and SQL Server as event streams. Kafka itself originated at LinkedIn and was open-sourced in 2011, which is why so much CDC vocabulary (topics, offsets, partitions) sounds like messaging rather than databases.
The architecture matters less than the properties it gives you. Events arrive in commit order per key. Consumers can replay from an offset. New consumers can be added without touching the source database. That last point is underrated: when a team wants to add a second vector index or a new evaluation pipeline, it subscribes to the stream instead of asking the database team for another export.
Where Teams Get It Wrong
Most CDC failures are operational, not conceptual. A few patterns repeat.
Treating deletes as an afterthought. Polling-based pipelines often miss hard deletes entirely, and even log-based pipelines need an explicit delete handler. If a document is removed from the source system for legal or privacy reasons, a vector index that only handles inserts and updates will keep serving it. Build the delete path first, not last.
Ignoring ordering across partitions. Events are ordered within a partition, not across the whole topic. If two updates to the same record land in different partitions, a consumer can apply them out of order and end up with stale content. Key your topics by record ID so related changes stay together.
Assuming exactly-once delivery end to end. Kafka’s log semantics and a capture tool’s offset handling help, but true exactly-once behavior depends on what the sink can do. Many vector databases and feature stores offer at-least-once semantics at best. The honest approach is to make writes idempotent, usually by keying on a version or timestamp, and to accept that duplicates are cheaper to handle than gaps.
Letting schema evolution break consumers. CDC events carry structure, and that structure changes. A new column, a renamed field, or a type change can silently break a downstream embedding job. A schema registry with explicit compatibility rules turns a silent break into a loud, early failure. This is the same discipline that keeps multi-tenant systems sane, as covered in this look at separating tenant data in an enterprise assistant.
Skipping the cost conversation. Change streams are cheap per event but not free at volume. Re-embedding every updated document can dominate your model spend, and cross-region replication adds egress charges that surprise finance teams. A clearer way to track cloud data transfer costs is worth reading before a pipeline goes live, because CDC volume grows with write traffic, not with user count.
Never testing recovery. A pipeline that has never been replayed from an old offset is a pipeline you do not understand. Snapshot-plus-stream bootstrap, offset resets, and consumer lag spikes all need rehearsing. The same mindset behind building a recovery drill for a managed database applies directly: know what a rebuild costs before you need one.
Practical Tips That Actually Work
Start with a narrow, high-value slice. Pick one collection that users ask about most and stream only that. Prove the freshness win, then expand.
Batch your embeddings. A document that changes five times in a minute does not need five re-embeds. Debounce updates in the consumer and embed once with the final state.
Keep raw events. Store the change events themselves rather than only their effects. When an embedding model is upgraded, you can replay history and rebuild the index without another full export.
Monitor lag as a first-class metric. Consumer lag, time since last event, and the age of the oldest unprocessed change tell you more about user-visible staleness than CPU graphs do.
Separate the capture layer from the AI layer. The database team owns capture. The AI team owns consumers. Clear ownership prevents the classic failure where nobody notices the connector died three days ago.
The Governance Angle
Freshness is also a compliance story, though a cautious one. The EU AI Act, Regulation (EU) 2024/1689, sets data governance expectations for high-risk AI systems, including relevance and representativeness of data. The regulation does not name change data capture, and anyone claiming a direct requirement is inferring. What CDC genuinely provides is evidence: a timestamped record of what data reached the model, when, and from where. That is useful for audits regardless of jurisdiction, and it is far easier to produce from an event log than from a pile of batch job logs. (A clearer way to track cloud data transfer costs)
When CDC Is the Wrong Tool
CDC is not a universal answer. If your source data changes weekly, a scheduled batch job is simpler and cheaper. If you cannot get log access from a managed database provider, polling may be your only option. If your AI system reads from an API rather than a database, you need webhook or polling strategies instead. And if the real problem is that your source data is wrong, streaming wrong data faster helps nobody.
The honest framing: CDC solves freshness and delivery. It does not solve data quality, chunking strategy, or retrieval relevance. Those remain separate problems with separate solutions.
Conclusion
Change data capture is unglamorous infrastructure, and that is exactly why it matters for AI. The models get the attention; the pipeline that decides whether they see this morning’s data or last week’s quietly determines whether users trust them. Log-based capture through tools like Debezium and Kafka Connect gives teams incremental updates, replayable history, and a clean separation between the database and the AI systems that depend on it. The teams that get this right tend to do three things: they handle deletes from day one, they make writes idempotent, and they rehearse recovery before they need it. Start small, measure lag, and treat freshness as a product feature rather than an afterthought.
Frequently Asked Questions
What is change data capture in simple terms?
Change data capture is a way of noticing every insert, update, and delete in a database and sending each one to other systems as it happens. Instead of copying the whole table on a schedule, you copy only what changed. That keeps downstream systems like search indexes and AI retrieval stores current without heavy repeated exports.
Why does AI need change data capture?
AI systems depend on current data. A retrieval-augmented assistant that cites outdated documents, or a model fed stale features, produces answers that look confident and are wrong. CDC lets vector indexes, feature stores, and evaluation datasets update incrementally as source records change, so what the model sees matches what is actually true.
Is log-based CDC better than polling?
Usually yes, for production systems. Log-based capture reads the database’s transaction log, which the database already maintains, so it adds little load and catches deletes that polling often misses. Polling is simpler to set up and sometimes the only option when a managed provider blocks log access, but it is slower and can skip changes between polls.
Does CDC guarantee exactly-once delivery?
Not by default. Messaging layers and capture tools can provide strong ordering and replay, but end-to-end exactly-once behavior depends on what the destination system supports. Many vector databases and feature stores offer at-least-once delivery at best. The practical fix is to make writes idempotent, keyed on a record version, so duplicates cause no harm.
How do you handle deleted documents in a vector index?
Handle deletes explicitly and early. Configure the capture tool to emit delete events, then have the consumer remove the corresponding vectors by their stable record ID. Test the path before launch. A pipeline that only processes inserts and updates will keep serving content that was deliberately removed, which is both a quality problem and a compliance risk.
How much does a CDC pipeline cost to run?
Costs come from three places: compute for capture and consumers, storage for retained events, and model calls for re-embedding updated content. Re-embedding usually dominates. Debouncing rapid updates, embedding only changed chunks, and watching cross-region data transfer keep the bill predictable. Volume scales with write traffic, not with the number of users.







