cockroachdb / cockroachdb/cockroach

sql/schemachanger: add optional syntax for ADD COLUMN to store new column in existing secondary indexes

Open
#111,380 0 comments 0 reactions 0 assignees View on GitHub
A-schema-changes C-enhancement T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Adding a new column when nullable is relatively cheap and only involves modifying the primary index to add a new storing column without *any* backfill. Unfortunately, there can be side effects for existing queries that use `SELECT *`, since they will now need to join between the primary and secondary index to resolve a row (i.e. finding columns not stored in the secondary index via the primary index).

One good alternative would be to add a new clause on ADD COLUMN so that indexes with STORING columns are all updated to include this column (or a user-selectable subset). This new syntax would update existing secondary indexes to add this new nullable column.

related: https://github.com/cockroachdb/cockroach/issues/98777

Jira issue: CRDB-31878

Epic CRDB-60817

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.