Skip to main content
Core and Enterprise changefeeds offer different levels of configurability. Enterprise changefeeds allow for active changefeed jobs to be paused, resumed, and canceled. This page describes:

Before you create a changefeed

  1. Enable rangefeeds on CockroachDB Advanced and CockroachDB self-hosted. Refer to Enable rangefeeds for instructions.
  2. Decide on whether you will run an Enterprise or basic changefeed. Refer to the page for a comparative capability table.
  3. Plan the number of changefeeds versus the number of tables to include in a single changefeed for your cluster. We recommend limiting the number of changefeeds per cluster to 80. Refer to System resources and running changefeeds and Recommendations for the number of target tables.
    • If you’re using a CockroachDB Cloud cluster, refer to for detail on how CDC is billed monthly based on usage.
  4. Consider whether your Enterprise changefeed use case would be better served by that can filter data on a single table. CDC queries can improve the efficiency of changefeeds because the job will not need to encode as much change data.
  5. Read the Considerations section that provides information on changefeed interactions that could affect how you configure or run your changefeed.

Enable rangefeeds

Changefeeds connect to a long-lived request called a rangefeed, which pushes changes as they happen. This reduces the latency of row changes, as well as reduces transaction restarts on tables being watched by a changefeed for some workloads. Rangefeeds must be enabled for a changefeed to work. To :
Any created changefeeds will error until this setting is enabled. If you are working on a CockroachDB Serverless cluster, the kv.rangefeed.enabled cluster setting is enabled by default. Enabling rangefeeds has a small performance cost (about a 5–10% increase in write latencies), whether or not the rangefeed is being used in a changefeed. When kv.rangefeed.enabled is set to true, a small portion of the latency cost is caused by additional write event information that is sent to the and for . The remainder of the latency cost is incurred once a changefeed is running; the write event information is reconstructed and sent to an active rangefeed, which will push the event to the changefeed. The kv.closed_timestamp.target_duration can be used with changefeeds. Resolved timestamps will always be behind by at least the duration configured by this setting. However, decreasing the duration leads to more transaction restarts in your cluster, which can affect performance. Refer to the for more detail.

Mux rangefeeds

MuxRangefeed is a subsystem that improves the performance of rangefeeds with scale. It significantly reduces the overhead of running rangefeeds. Without MuxRangefeed enabled the number of RPC streams is proportional with the number of ranges in a table. For example, a large table could have tens of thousands of ranges. With MuxRangefeed enabled, this proportion improves so that the number of RPC streams is relative to the number of nodes in a cluster. We recommend enabling its functionality with the changefeed.mux_rangefeed.enabled . In v24.1 and later versions, MuxRangefeed is enabled by default. Use the following workflow to enable MuxRangefeed:
  1. Enable the cluster setting:
  2. After enabling the setting, pause the changefeed:
    You can use to retrieve the job ID.
  3. Resume the changefeed for the cluster setting to take effect:

Recommendations for the number of target tables

When creating a changefeed, it’s important to consider the number of changefeeds versus the number of tables to include in a single changefeed:
  • Changefeeds each have their own memory overhead, so every running changefeed will increase total memory usage.
  • Creating a single changefeed that will watch hundreds of tables can affect the performance of a changefeed by introducing coupling, where the performance of a target table affects the performance of the changefeed watching it. For example, any on any of the tables will affect the entire changefeed’s performance.
To watch multiple tables, we recommend creating a changefeed with a comma-separated list of tables. However, we do not recommend creating a single changefeed for watching hundreds of tables. Cockroach Labs recommends monitoring your changefeeds to track and usage. Refer to the page for more information.

System resources and running changefeeds

When you are running more than 10 changefeeds on a cluster, it is important to monitor the . A larger cluster will be able to run more changefeeds concurrently compared to a smaller cluster with more limited resources. We recommend limiting the number of changefeeds per cluster to 80. To maintain a high number of changefeeds in your cluster:
  • Connect to different nodes to create each changefeed. The node on which you start the changefeed will become the coordinator node for the changefeed job. The coordinator node acts as an administrator: keeping track of all other nodes during job execution and the changefeed work as it completes. As a result, this node will use more resources for the changefeed job. Refer to for more detail.
  • Consider logically grouping the target tables into one changefeed. When a changefeed pauses, it will stop emitting messages for the target tables. Grouping tables of related data into a single changefeed may make sense for your workload. However, we do not recommend watching hundreds of tables in a single changefeed. Refer to for more detail on protecting data from garbage collection when a changefeed is paused.

Considerations

  • If you require message frequency under 30s, then you must set the option to at least the desired resolved frequency.
  • Many DDL queries (including , , and queries that add a column family) will cause errors on a changefeed watching the affected tables. You will need to . If a table is truncated that a changefeed with on_error='pause' is watching, you will also need to start a new changefeed. Refer to the change data capture Known Limitations for more detail.
  • Partial or intermittent sink unavailability may impact changefeed stability. If a sink is unavailable, messages can’t send, which means that a changefeed’s high-water mark timestamp is at risk of falling behind the cluster’s . Throughput and latency can be affected once the sink is available again. However, will still hold for as long as a changefeed .
  • When an statement is run, any current changefeed jobs targeting that table will fail.
  • After you , changefeed jobs will not resume on the new cluster. It is necessary to manually create the changefeeds following the full-cluster restore.
  • As of v22.1, changefeeds filter out from events by default. This is a . To maintain the changefeed behavior in previous versions where values are emitted for virtual computed columns, see the option for more detail.
The following Enterprise and Core sections outline how to create and configure each type of changefeed:

Configure a changefeed

An Enterprise changefeed streams row-level changes in a configurable format to a configurable sink (i.e., Kafka or a cloud storage sink). You can create, pause, resume, and cancel an Enterprise changefeed. For a step-by-step example connecting to a specific sink, see the page.

Create

To create an Enterprise changefeed:
Parameters should always be URI-encoded before they are included the changefeed’s URI, as they often contain special characters. Use Javascript’s encodeURIComponent function or Go language’s url.QueryEscape function to URI-encode the parameters. Other languages provide similar functions to URI-encode special characters.
When you create a changefeed without specifying a sink, CockroachDB sends the changefeed events to the SQL client. Consider the following regarding the in your SQL client:
  • If you do not define a display format, the CockroachDB SQL client will automatically use ndjson format.
  • If you specify a display format, the client will use that format (e.g., --format=csv ).
  • If you set the client display format to ndjson and set the changefeed to csv, you’ll receive JSON format with CSV nested inside.
  • If you set the client display format to csv and set the changefeed to json, you’ll receive a comma-separated list of JSON values.
For more information, see .

Show

To show a list of Enterprise changefeed jobs:
To show an individual Enterprise changefeed:
All changefeed jobs will display regardless of if the job completed and when it completed. You can define a retention time and delete completed jobs by using the jobs.retention_time .You can filter the columns that SHOW CHANGEFEED JOBS displays using a SELECT statement:
For more information, refer to .

Pause

To pause an Enterprise changefeed:
For more information, refer to .

Resume

To resume a paused Enterprise changefeed:
For more information, refer to .

Cancel

To cancel an Enterprise changefeed:
For more information, refer to .

Modify a changefeed

To modify an Enterprise changefeed, the job and then use:
You can add new table targets, remove them, set new , and unset them.For more information, see .

Configuring all changefeeds

It is useful to be able to pause all running changefeeds during troubleshooting, testing, or when a decrease in CPU load is needed.To pause all running changefeeds:
This will change the status for each of the running changefeeds to paused, which can be verified with .To resume all running changefeeds:
This will resume the changefeeds and update the status for each of the changefeeds to running.

Known limitations

  • Changefeed target options are limited to tables and .
  • and in CockroachDB Advanced clusters do not support connecting to a sink’s internal IP addresses for . To connect to a Kafka sink from CockroachDB Advanced, it is necessary to expose the Kafka cluster’s external IP address and open ports with firewall rules to allow access from a CockroachDB Advanced cluster.
  • Webhook sinks only support HTTPS. Use the parameter when testing to disable certificate verification; however, this still requires HTTPS and certificates.
  • Formats for changefeed messages are not supported by all changefeed sinks. Refer to the page for details on compatible formats with each sink and the option to specify a changefeed message format.
  • Using the and options on the same changefeed will cause an error when using the following : Kafka and Google Cloud Pub/Sub. Instead, use the individual FAMILY keyword to specify column families when creating a changefeed.
  • Changefeed types are not fully integrated with . Running changefeeds with user-defined composite types is in . Certain changefeed types do not support user-defined composite types. Refer to the change data capture for more detail. The following limitations apply:
    • A changefeed in will not be able to serialize .
    • A changefeed emitting will include AS labels in the message format when the changefeed serializes a .
  • After the for , will continue on the promoted cluster. You will need to manage or the schedule on the promoted standby cluster to avoid two clusters running the same changefeed to one sink.
  • In v23.2.0, changefeeds that use the set to a could create a plan that assigns most of the ranges to an on the coordinator node. This leads to an unbalanced plan and slow changefeed progress, particularly when the table is large and has many ranges. This issue is partially mitigated in v23.2.1 and later.
  • is not fully supported with changefeeds that use . You can alter the options that a changefeed uses, but you cannot alter the changefeed target tables.
  • Creating a changefeed with on tables with more than one is not supported.
  • When you create a changefeed on a table with more than one , the changefeed will emit messages per column family in separate streams. As a result, for different column families will arrive at the under separate topics.

See also