Skip to content

opt: prune unnecessary check columns#56007

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
mgartner:prune-check-cols
Oct 28, 2020
Merged

opt: prune unnecessary check columns#56007
craig[bot] merged 1 commit intocockroachdb:masterfrom
mgartner:prune-check-cols

Conversation

@mgartner
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

bors r=RaduBerinde

@craig
Copy link
Copy Markdown
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