-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: minor improvements around estimated row count #118679
Conversation
This commit makes it so that we use the ceiling of the estimated row count in scans and aggregation. It also fixes recently-introduced bug that could cause integer overflow in the agg alloc code. Release note: None
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
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 6 of 6 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @yuzefovich)
pkg/sql/colexec/hash_aggregator.go
line 205 at r1 (raw file):
if args.EstimatedRowCount != 0 { // Use uint64s for comparison to prevent overflow in case // args.EstimatedRowCount is larger than MaxInt64.
So the estimated row count from the optimizer is fine, just overflowing here? Good catch!
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! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @mgartner)
pkg/sql/colexec/hash_aggregator.go
line 205 at r1 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
So the estimated row count from the optimizer is fine, just overflowing here? Good catch!
I think so - the problem occurred because we took the estimated row count (which is uint64
and could be very large), then down-casted it to int64
possibly producing negative numbers. This change prevents that from happening.
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 6 of 6 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @mgartner)
TFTRs! bors r+ |
Build failed (retrying...): |
Build succeeded: |
This commit makes it so that we use the ceiling of the estimated row count in scans and aggregation. It also fixes recently-introduced bug that could cause integer overflow in the agg alloc code.
Fixes: #118724.
Epic: None
Release note: None