New in v22.1:
When you create an Enterprise changefeed, you can include the initial_scan = 'only'
option to specify that the changefeed should only complete a table scan. The changefeed emits messages for the table scan and then the job completes with a succeeded
status. As a result, you can create a changefeed with initial_scan = 'only'
to export data out of your database.
The benefits of using changefeeds for this function compared to an export, include:
- Changefeeds are jobs, which can be paused, resumed, and cancelled.
- There is observability into a changefeed job using
SHOW CHANGEFEED JOBS
and the Changefeeds Dashboard in the DB Console. - Changefeed sinks provide additional endpoints to send your data.
- You can use the
format=csv
option withinitial_scan= 'only'
to emit messages in CSV format.
Although this option offers an alternative way to export data out of your database, it is necessary to consider the following when you use CREATE CHANGEFEED
instead of EXPORT
:
- Changefeeds do not offer any filtering capabilities.
- Changefeeds can emit duplicate messages.
You cannot use the new initial_scan = "yes"/"no"/"only"
syntax with
ALTER CHANGEFEED
in v22.1. To ensure that you can modify a changefeed with the initial_scan
options, use the previous syntax of initial_scan
, no_initial_scan
, and initial_scan_only
.
To create a changefeed that will only complete an initial scan of a table(s), run the following:
CREATE CHANGEFEED FOR TABLE movr.users INTO '{scheme}://{host}:{port}?{query_parameters}' WITH initial_scan = 'only', format=csv;
The job will return a job ID once it has started. You can use SHOW CHANGEFEED JOBS
to check on the status:
SHOW CHANGEFEED JOB {job ID};
When the scan has completed you will find the output shows succeeded
in the status
field.