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

opt: prune unnecessary check columns #56007

Merged
merged 1 commit into from
Oct 28, 2020

Conversation

mgartner
Copy link
Collaborator

This commit updates the optimizer to prune synthesized CHECK
constraint columns for UPDATES when columns referenced in the
constraints are not updated. This may also allow the optimizer to no
longer fetch those referenced columns.

This should provide a performance benefit for UDPATEs to tables with
check constraints. Notably, tables that have been given many column
families (in order to reduce contention) should see a significant
reduction in contention for UPDATEs that mutate a subset of column
families.

Informs #51526

Release note (performance improvement): Previously, all CHECK
constraints defined on a table would be tested for every UPDATE to the
table. Now, a check constraint will not be tested for validity when the
values of columns it references are not being updated. The referenced
columns are no longer fetchecd in cases where they were only fetched to
test CHECK constraints.

@mgartner mgartner requested a review from a team as a code owner October 27, 2020 02:02
@cockroach-teamcity
Copy link
Member

This change is Reviewable

This commit updates the optimizer to prune synthesized `CHECK`
constraint columns for `UPDATES` when columns referenced in the
constraints are not updated. This may also allow the optimizer to no
longer fetch those referenced columns.

This should provide a performance benefit for `UDPATE`s to tables with
check constraints. Notably, tables that have been given many column
families (in order to reduce contention) should see a significant
reduction in contention for `UPDATE`s that mutate a subset of column
families.

Informs cockroachdb#51526

Release note (performance improvement): Previously, all `CHECK`
constraints defined on a table would be tested for every `UPDATE` to the
table. Now, a check constraint will not be tested for validity when the
values of columns it references are not being updated. The referenced
columns are no longer fetchecd in cases where they were only fetched to
test `CHECK` constraints.
Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: Nice improvements to the TPCE plans!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde and @rytaft)

@mgartner
Copy link
Collaborator Author

bors r=RaduBerinde

@craig
Copy link
Contributor

craig bot commented Oct 28, 2020

Build succeeded:

@craig craig bot merged commit db07523 into cockroachdb:master Oct 28, 2020
@mgartner mgartner deleted the prune-check-cols branch October 28, 2020 16:07
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.

3 participants