-
Notifications
You must be signed in to change notification settings - Fork 3.9k
opt: do not produce unneeded PK cols in inverted index scans #147490
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
Conversation
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 r1, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @michae2)
pkg/sql/opt/xform/select_funcs.go
line 974 at r1 (raw file):
// the original scan. newScanPrivate.Cols = pkCols.Copy() newScanPrivate.Cols.IntersectionWith(scanPrivate.Cols)
[super nit] you can make this a one-liner :)
newScanPrivate.Cols = pkCols.Intersection(scanPrivate.Cols)
pkg/sql/opt/xform/select_funcs.go
line 1009 at r1 (raw file):
// by the scan. filters = sb.AddSelectAfterSplit(filters, pkCols) if needIndexJoin {
If we don't need an index join but do need an inverted filter, do we need to project away unneeded primary key columns?
A minor bug has been fixed where an inverted index scan could produce more PK columns than necessary. This caused test-only assertion failures but does not cause any known, user-visible bugs. The bug was caused by the incorrect assumption that all inverted index scans need to produces all PK columns. In actuality, an inverted index scan can produce a subset of PK columns if the original scan produces a subset of PK columns and neither an inverted filter nor an index join are needed. Fixes cockroachdb#143070 Release note: None
4a291ff
to
2e0b93c
Compare
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.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball and @michae2)
pkg/sql/opt/xform/select_funcs.go
line 974 at r1 (raw file):
Previously, DrewKimball (Drew Kimball) wrote…
[super nit] you can make this a one-liner :)
newScanPrivate.Cols = pkCols.Intersection(scanPrivate.Cols)
Ya, I debated it. I wanted to make the copy explicit since it's critical. I switched to your suggestion and added a note.
pkg/sql/opt/xform/select_funcs.go
line 1009 at r1 (raw file):
Previously, DrewKimball (Drew Kimball) wrote…
If we don't need an index join but do need an inverted filter, do we need to project away unneeded primary key columns?
Yes, that's already handled by the scan builder. See #141670 and the test directly about the one I added in this PR.
s/about/above |
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, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @michae2)
TFTR! bors r+ |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. error creating merge commit from 2e0b93c to blathers/backport-release-23.2-147490: 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 release-23.2 failed. See errors above. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. error creating merge commit from 2e0b93c to blathers/backport-release-24.1-147490: 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 release-24.1 failed. See errors above. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. error creating merge commit from 2e0b93c to blathers/backport-release-24.3-147490: 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 release-24.3 failed. See errors above. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. error creating merge commit from 2e0b93c to blathers/backport-release-25.1-147490: 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 release-25.1 failed. See errors above. 💡 Consider backporting to the fork repo instead of the main repo. See instructions for more details. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
I'm going to hold-off on backporting to anything other than 25.2. If we continue to see these failures on older release branches, we can try to backport this, but we'll likely also need to backport #141670. |
A minor bug has been fixed where an inverted index scan could produce
more PK columns than necessary. This caused test-only assertion failures
but does not cause any known, user-visible bugs. The bug was caused by
the incorrect assumption that all inverted index scans need to produces
all PK columns. In actuality, an inverted index scan can produce a
subset of PK columns if the original scan produces a subset of PK
columns and neither an inverted filter nor an index join are needed.
Fixes #143070
Release note: None