Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/current/v26.1/changefeed-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ You can also use the [`schema_change_events`]({% link {{ page.version.version }}

## Lock the schema on changefeed watched tables

To apply `schema_locked` automatically to new tables, set the [`create_table_with_schema_locked` session variable]({% link {{ page.version.version }}/set-vars.md %}#create_table_with_schema_locked). In CockroachDB v26.1 and later, it defaults to `on`.

{% include {{ page.version.version }}/cdc/cdc-schema-locked-example.md %}

## See also
Expand Down
6 changes: 6 additions & 0 deletions src/current/v26.1/online-schema-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ For advice about how to avoid running out of space during an online schema chang

## Best practices for online schema changes

### Improve changefeed performance with `schema_locked`

Set the [`schema_locked` table storage parameter]({% link {{ page.version.version }}/with-storage-parameter.md %}#storage-parameter-schema-locked) to `true` to indicate that a schema change is not currently ongoing on a table. CockroachDB automatically unsets this parameter before performing a schema change and reapplies it when done. Enabling `schema_locked` can help [improve performance of changefeeds]({% link {{ page.version.version }}/create-changefeed.md %}#disallow-schema-changes-on-tables-to-improve-changefeed-performance) running on the table, which can reduce commit-to-emit latency.

Use the [`create_table_with_schema_locked` session variable]({% link {{ page.version.version }}/set-vars.md %}#create_table_with_schema_locked) to set this storage parameter on every table created in the session. In v26.1 and later, it is enabled by default.

### Estimate your storage capacity before performing online schema changes

Some schema change operations, like adding or dropping columns or altering primary keys, will temporarily increase a cluster's storage consumption. Specifically, these operations may temporarily require up to three times more storage space for the range size while the schema change is being applied, and this may cause the cluster to run out of storage space or fail to apply the schema change.
Expand Down
Loading