-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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,ccl: eliminate Project inside GroupBy, add tests for validation of partial unique indexes #67263
Conversation
Hold off on reviewing this -- I need to make a change. |
This commit adds a check that NullsAreDistinct is true iff the grouping operator is UpsertDistinctOn or EnsureUpsertDistinctOn. Release note: None
ec2b87b
to
fece174
Compare
This commit updates the exploration rule EliminateIndexJoinInsideGroupBy and renames it to EliminateIndexJoinOrProjectInsideGroupBy. The rule now removes either an IndexJoin or Project operator if it can be proven that the removal does not affect the output of the parent grouping operator. Removal of a Project is needed in cases where the partial index predicate constrains some columns to be constant, and therefore provides those columns as constant projections. If the projected columns are not actually needed by the GroupBy, however, the Project is not necessary and interferes with other rules matching, such as SplitGroupByScanIntoUnionScans. Informs cockroachdb#65473 Release note (performance improvement): Improved the efficiency of validation for some partial unique indexes in REGIONAL BY ROW tables by improving the query plan to use all streaming operations.
This commit adds tests to ensure that the expected query plan is used to validate new partial unique indexes in REGIONAL BY ROW tables. Release note: None
Ok, RFAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2, 6 of 6 files at r3, 1 of 1 files at r4.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @cucaroach and @rytaft)
pkg/ccl/logictestccl/testdata/logic_test/regional_by_row, line 1560 at r4 (raw file):
│ estimated row count: 10 │ ├── • union all
I think it would be helpful for users if EXPLAIN clearly showed that these union-all's are locality optimized. Definitely not necessary for this PR, but what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTR!
bors r+
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @cucaroach and @mgartner)
pkg/ccl/logictestccl/testdata/logic_test/regional_by_row, line 1560 at r4 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
I think it would be helpful for users if EXPLAIN clearly showed that these union-all's are locality optimized. Definitely not necessary for this PR, but what do you think?
These UNION ALLs aren't actually locality optimized -- they are streaming due to the ordering on +b
. #66211 is already open to improve EXPLAIN for locality optimized UNION ALLs, but that wouldn't apply here (locality optimized UNION ALL must have a limit).
We could make it clearer that this is a streaming op, I guess -- is that what you had in mind? (In that case, we'd also want to make that change for group by...)
Build succeeded: |
pkg/ccl/logictestccl/testdata/logic_test/regional_by_row, line 1560 at r4 (raw file): Previously, rytaft (Rebecca Taft) wrote…
Heh, ya I was confused, sorry. Thanks for the link to #66211. But yes, I think our cc'ing @vy-ton to help prioritize this. |
opt: add a test-only check for
NullsAreDistinct
inGroupingPrivate
This commit adds a check that
NullsAreDistinct
is true iff the groupingoperator is
UpsertDistinctOn
orEnsureUpsertDistinctOn
.Release note: None
opt: add exploration rule to eliminate
Project
insideGroupBy
This commit updates the exploration rule
EliminateIndexJoinInsideGroupBy
and renames it to
EliminateIndexJoinOrProjectInsideGroupBy
. The rule nowremoves either an
IndexJoin
orProject
operator if it can be proven thatthe removal does not affect the output of the parent grouping operator.
Removal of a
Project
is needed in cases where the partial index predicateconstrains some columns to be constant, and therefore provides those
columns as constant projections. If the projected columns are not actually
needed by the
GroupBy
, however, theProject
is not necessary and interfereswith other rules matching, such as
SplitGroupByScanIntoUnionScans
.Informs #65473
Release note (performance improvement): Improved the efficiency of validation
for some partial unique indexes in
REGIONAL BY ROW
tables by improving thequery plan to use all streaming operations.
ccl: add tests for validation of partial unique indexes
This commit adds tests to ensure that the expected query plan is used
to validate new partial unique indexes in
REGIONAL BY ROW
tables.Informs #65473
Release note: None