-
Notifications
You must be signed in to change notification settings - Fork 6.1k
planner: out of range common prefix | tidb-test=pr/2630 #64510
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
base: master
Are you sure you want to change the base?
Conversation
|
Hi @terry1purcell. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #64510 +/- ##
================================================
+ Coverage 72.6816% 73.6265% +0.9448%
================================================
Files 1866 1889 +23
Lines 506282 514399 +8117
================================================
+ Hits 367974 378734 +10760
+ Misses 115918 112741 -3177
- Partials 22390 22924 +534
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest-required |
|
@terry1purcell: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
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.
Pull Request Overview
This PR addresses issue #64378 related to "out of range common prefix" estimation in the query planner. The fix improves cardinality estimation when query ranges fall outside histogram bounds, particularly for string/byte comparisons where common prefix comparison results in equal scalar values (l == r).
Key changes:
- Added
highIsOpenEndedparameter toOutOfRangeRowCountto detect open-ended ranges (e.g., when upper bound is MaxValue) - Moved
addedRowsandmodifyCountcalculations earlier in the function to enable their use in thel == rcase - Added special handling for
l == rscenario with different estimates based on whether the range is open-ended - Changed the condition from
l >= rto separatel > randl == rcases for more accurate handling
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/statistics/histogram.go | Core logic changes: added highIsOpenEnded parameter, moved calculations, and added special handling for l == r case |
| pkg/planner/cardinality/row_count_index.go | Updated all call sites to detect and pass highIsOpenEnded flag based on index range high values |
| pkg/planner/cardinality/row_count_column.go | Updated call site to detect and pass highIsOpenEnded flag based on column range high values |
| tests/integrationtest/r/planner/cardinality/selectivity.result | Updated expected test results showing increased row count estimates from 1.00 to 2.00 for various queries |
| tests/integrationtest/r/imdbload.result | Updated expected test results showing increased row count estimates (e.g., from 2.00 to 6.65, from 1.00 to 3.32) |
mjonss
left a comment
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.
So this will only change the estimate for open ended queries like WHERE b > 6 but not WHERE b BETWEEN 6 AND 2000000?
What problem does this PR solve?
Issue Number: ref #64378
Problem Summary:
What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.