Skip to main content
Change data capture (CDC) detects row-level data changes in CockroachDB and emits those changes as messages for downstream processing. While CockroachDB is an excellent system of record, CDC allows it to integrate with other systems in your data ecosystem. For example, you might want to:
  • Stream messages to Kafka to trigger notifications in an application.
  • Mirror your data in full-text indexes, analytics engines, or big data pipelines.
  • Export a snapshot of tables to backfill new applications.
  • Feed updates to data stores powering machine learning models.

Stream row-level changes with changefeeds

Changefeeds are customizable jobs that monitor row-level changes in a table and emit updates in real time. These updates are delivered in your preferred format to a specified destination, known as a sink. In production, changefeeds are typically configured with an external sink such as Kafka or cloud storage. However, for development and testing purposes, sinkless changefeeds allow you to stream change data directly to your SQL client. Each emitted row change is delivered at least once, and the first emit of every event for the same key is ordered by timestamp.
Sinkless changefeedsChangefeeds
Use caseUseful for prototyping or quick testing.Recommended for production use.
Product availabilityAll productsAll products
Message deliveryStreams indefinitely until underlying SQL connection is closed.Maintains connection to configured .
SQL statementCreate with Create with
TargetsWatches one or multiple tables in a comma-separated list.Watches one or multiple tables in a comma-separated list.
Filter change dataUse to define the emitted change data.Use to define the emitted change data.
Schedule changefeedsNot supportedCreate a scheduled changefeed with .
Job execution localityNot supportedUse to determine the node locality for changefeed job execution.
Message formatEmits every change to a “watched” row as a record to the current SQL session.Emits every change to a “watched” row as a record in a .
ManagementCreate the changefeed and cancel by closing the SQL connection. with CREATE, PAUSE, RESUME, ALTER, and CANCEL.
MonitoringNot supported available to monitor in the DB Console and Prometheus. Job observability with .

Get started with changefeeds

To get started with changefeeds in CockroachDB, refer to:
  • : Learn about the fundamentals of using SQL statements to create and manage changefeeds.
  • : The downstream system to which the changefeed emits changes. Learn about the supported sinks and configuration capabilities.
  • : The change events that emit from the changefeed. Learn about how messages are ordered and the options to configure and format messages.
  • : Step-by-step examples for connecting to changefeed sinks or running sinkless changefeeds.

Authenticate to your changefeed sink

To send changefeed messages to a sink, it is necessary to provide the CREATE CHANGEFEED statement with authentication credentials. The following pages detail the supported authentication:
SinkAuthentication page
Cloud StorageRefer to for detail on setting up:
  • IAM roles with assume role authentication.
  • Workload identity authentication.
  • Implicit authentication.
  • Specified authentication.
KafkaRefer to:
  • to connect to your Kafka sink using OAuth authentication.
  • to authenticate to a Confluent Cloud Kafka cluster with a Confluent Schema Registry.
  • to supply your own certificate credentials.
WebhookRefer to:
  • to supply your own certificate credentials.
Google Cloud Pub/SubRefer to:
  • for a general list of the supported query parameters.
  • for detail on IAM roles with assume role authentication.

Monitor your changefeed job

It is a best practice to monitor your changefeed jobs for behavior such as failures and retries. You can use the following tools for monitoring:
  • The on the DB Console
  • The statement
Refer to the page for recommendations on metrics to track. For detail on how protected timestamps and garbage collection interact with changefeeds, refer to .

Optimize a changefeed for your workload

Filter your change data with CDC queries

Change data capture queries allow you to define and filter the change data emitted to your sink when you create an changefeed. For example, you can use CDC queries to:
  • from changefeed messages to decrease the load on your downstream sink.
  • to reduce the time and operational burden of filtering or transforming data downstream.
  • of your changefeed messages for increased compatibility with external systems.
Refer to the page for more example use cases.

Use changefeeds to export a table

Changefeeds can export a single table scan to your sink. The benefits of using changefeeds for exports include: job management, observability, and sink configurability. You can also schedule changefeeds to export tables, which may be useful to avoid table scans during peak periods. For examples and more detail, refer to:

Determine the nodes running a changefeed by locality

CockroachDB supports an option to set locality filter requirements that nodes must meet in order to take part in a changefeed job. This is helpful in multi-region clusters to ensure the nodes that are physically closest to the sink emit changefeed messages. For syntax and further technical detail, refer to .