opt: match ScalarGroupBy in EliminateIndexJoinOrProjectInsideGroupBy#70120
Conversation
This commit extends EliminateIndexJoinOrProjectInsideGroupBy so that
ScalarGroupBy expressions are also matched. This allows the rule to
eliminate unnecessary index joins in more cases.
The primary motivation for this change was to make partial index
validation queries more efficient. These queries always have
ScalarGroupBy expressions because they are in the form:
SELECT count(1) FROM table@partial_index WHERE predicate
Prior to this change, an index join was planned for these queries which
would operate on every row in the partial index. This could be extremely
expensive for large partial indexes.
Fixes cockroachdb#70116
Release note (performance improvement): A limitation has been fixed that
made creating partial indexes inefficient.
aabc3e8 to
2751851
Compare
RaduBerinde
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @rytaft)
RaduBerinde
left a comment
There was a problem hiding this comment.
What is a partial index validation query used for?
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @rytaft)
RaduBerinde
left a comment
There was a problem hiding this comment.
Ah, never mind, we do it just to double-check the backfill.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @rytaft)
|
TFTR! bors r+ |
|
Build succeeded: |
|
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from 2751851 to blathers/backport-release-21.1-70120: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 21.1.x failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
|
Backporting this to 21.1 would require also backporting 64bb06a. Given that there is a workaround for this (STORING the columns referenced in the predicate), I'm inclined to not backport to 21.1. |
This commit extends EliminateIndexJoinOrProjectInsideGroupBy so that
ScalarGroupBy expressions are also matched. This allows the rule to
eliminate unnecessary index joins in more cases.
The primary motivation for this change was to make partial index
validation queries more efficient. These queries always have
ScalarGroupBy expressions because they are in the form:
Prior to this change, an index join was planned for these queries which
would operate on every row in the partial index. This could be extremely
expensive for large partial indexes.
Fixes #70116
Release note (performance improvement): A limitation has been fixed that
made creating partial indexes inefficient.