Skip to content

sql: add skip_rbr_unique_rowid_checks storage parameter for RBR tables#161535

Draft
DrewKimball wants to merge 1 commit intocockroachdb:masterfrom
DrewKimball:unique-storage-param
Draft

sql: add skip_rbr_unique_rowid_checks storage parameter for RBR tables#161535
DrewKimball wants to merge 1 commit intocockroachdb:masterfrom
DrewKimball:unique-storage-param

Conversation

@DrewKimball
Copy link
Copy Markdown
Collaborator

Previously, REGIONAL BY ROW tables performed expensive cross-region uniqueness checks for all unique indexes and constraints, including those on columns with unique_rowid() or unordered_unique_rowid() defaults. These functions generate globally unique values with near-zero collision probability, making cross-region checks unnecessary overhead.

This commit adds a new storage parameter skip_rbr_unique_rowid_checks that can be set on REGIONAL BY ROW tables to skip cross-region uniqueness checks for columns using unique_rowid() or unordered_unique_rowid(). The optimization applies to:

  • Columns with DEFAULT unique_rowid() or unordered_unique_rowid().
  • Both INSERT and UPDATE operations.
  • Primary indexes, unique secondary indexes, and UNIQUE WITHOUT INDEX.

The parameter can only be set on REGIONAL BY ROW tables and is automatically unset when changing to REGIONAL BY TABLE or GLOBAL locality. User-specified values continue to receive full uniqueness checks across regions, ensuring correctness. A notice is displayed upon setting the parameter warning not to mix user-supplied values in a column with a unique_rowid()-implied uniqueness constraint.

Epic: CRDB-39721

Release note (performance improvement): Added storage parameter skip_rbr_unique_rowid_checks for REGIONAL BY ROW tables to skip expensive cross-region uniqueness checks on columns using unique_rowid() or unordered_unique_rowid() as the default expression. This improves performance for multi-region tables while maintaining correctness guarantees.

Previously, REGIONAL BY ROW tables performed expensive cross-region
uniqueness checks for all unique indexes and constraints, including
those on columns with unique_rowid() or unordered_unique_rowid()
defaults. These functions generate globally unique values with
near-zero collision probability, making cross-region checks
unnecessary overhead.

This commit adds a new storage parameter `skip_rbr_unique_rowid_checks`
that can be set on REGIONAL BY ROW tables to skip cross-region
uniqueness checks for columns using unique_rowid() or
unordered_unique_rowid(). The optimization applies to:
- Columns with DEFAULT unique_rowid() or unordered_unique_rowid().
- Both INSERT and UPDATE operations.
- Primary indexes, unique secondary indexes, and UNIQUE WITHOUT INDEX.

The parameter can only be set on REGIONAL BY ROW tables and is
automatically unset when changing to REGIONAL BY TABLE or GLOBAL
locality. User-specified values continue to receive full uniqueness
checks across regions, ensuring correctness. A notice is displayed upon
setting the parameter warning not to mix user-supplied values in a
column with a unique_rowid()-implied uniqueness constraint.

Epic: CRDB-39721

Release note (performance improvement): Added storage parameter
`skip_rbr_unique_rowid_checks` for REGIONAL BY ROW tables to skip
expensive cross-region uniqueness checks on columns using
unique_rowid() or unordered_unique_rowid() as the default expression.
This improves performance for multi-region tables while maintaining
correctness guarantees.
@DrewKimball DrewKimball requested a review from a team January 21, 2026 20:34
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Jan 21, 2026

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants