-
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
release-22.2: stats: fix buckets for INT2 and INT4 #88214
Conversation
c38fdeb
to
9edd5be
Compare
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
Looks like |
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 4 of 10 files at r1, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @rytaft and @yuzefovich)
9edd5be
to
2e0f4e9
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.
Reviewed 9 of 10 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @blathers-crl[bot] and @yuzefovich)
pkg/sql/stats/histogram.go
line 365 at r2 (raw file):
switch t.Width() { case 16: if i == math.MinInt16 {
What if i
is less than MinInt16
? Can that ever happen? Same question below for 32 and for MaxInt16
/ MaxInt32
also
(sorry I didn't review the PR on master -- guessing this is fine, but just wanted to check...)
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 (and 1 stale) (waiting on @rytaft)
pkg/sql/stats/histogram.go
line 365 at r2 (raw file):
Previously, rytaft (Rebecca Taft) wrote…
What if
i
is less thanMinInt16
? Can that ever happen? Same question below for 32 and forMaxInt16
/MaxInt32
also(sorry I didn't review the PR on master -- guessing this is fine, but just wanted to check...)
Hm, this shouldn't really happen because it would imply that we sampled such a value which would mean that we didn't perform the out of bounds check on the write path. However, I'm not confident that we actually do those checks in all places, so it'd be worth being conservative here. I'll open up a PR for this - thanks!
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 (and 1 stale) (waiting on @yuzefovich)
pkg/sql/stats/histogram.go
line 365 at r2 (raw file):
Previously, yuzefovich (Yahor Yuzefovich) wrote…
Hm, this shouldn't really happen because it would imply that we sampled such a value which would mean that we didn't perform the out of bounds check on the write path. However, I'm not confident that we actually do those checks in all places, so it'd be worth being conservative here. I'll open up a PR for this - thanks!
Thanks!
Previously, if we needed to create "outer" histogram buckets (which is the case when minimum and maximum values in the column weren't sampled yet they contributed to the distinct count) for INT2 and INT4 types, we would use the values that exceeded the supported range for those types. This could lead to incorrect estimation later on when those "outer" buckets are used during the costing as well as the histograms would need to be manually edited to be injected. This is now fixed by handling these two types separately. Release note: None
2e0f4e9
to
9da6f98
Compare
Squashed #88300 into this commit. |
Backport 1/1 commits from #88083 on behalf of @yuzefovich.
/cc @cockroachdb/release
Previously, if we needed to create "outer" histogram buckets (which is the case when minimum and maximum values in the column weren't sampled yet they contributed to the distinct count) for INT2 and INT4 types, we would use the values that exceeded the supported range for those types. This could lead to incorrect estimation later on when those "outer" buckets are used during the costing as well as the histograms would need to be manually edited to be injected. This is now fixed by handling these two types separately.
Fixes: #76887.
Release note: None
Release justification: bug fix.