Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: require CASCADE to drop physical shard column of hash index #80181

Closed
ajwerner opened this issue Apr 19, 2022 · 0 comments · Fixed by #80806
Closed

sql: require CASCADE to drop physical shard column of hash index #80181

ajwerner opened this issue Apr 19, 2022 · 0 comments · Fixed by #80806
Assignees
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@ajwerner
Copy link
Contributor

ajwerner commented Apr 19, 2022

Is your feature request related to a problem? Please describe.

In 21.2 and prior, hash-sharded indexes (USING HASH) created a physical, STORED computed column. When we drop the index and find that no other index is using the column, we drop the column too. This can be surprising to users. Dropping a column is much more expensive than dropping an index; dropping a column requires a full rewrite of the table. Also, dropping a column can be disruptive to changefeeds (#35738).

Describe the solution you'd like

We should require CASCADE to drop an index which implies the drop of a shard column.

Describe alternatives you've considered
We could, additionally, provide some syntax to prevent the index from dropping the shard column. We could also just never drop the shard column. Perhaps one approach is to have a session variable to not drop the shard column and reference it in the error message when cascade is not provided.

Additional context

#77316 made dropping shard columns or adding them somewhat less painful for changefeeds, but until we remove the column backfill (#47989, hopefully in 22.2), dropping the column remains very painful because of #35738.

For hash indexes created in 22.1 and later, this issue isn't really relevant. Dropping a virtual computed column is no problem. Nevertheless, tables with physical shard columns can exist in later versions because of upgrades or restores.

Jira issue: CRDB-15819

@ajwerner ajwerner added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Apr 19, 2022
@Xiang-Gu Xiang-Gu self-assigned this Apr 19, 2022
@craig craig bot closed this as completed in f2d5708 May 5, 2022
@craig craig bot closed this as completed in #80806 May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants