-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
statistics: improve estimation for index equal condition #17366
Conversation
/run-unit-test |
if i >= usedColsLen { | ||
break | ||
} | ||
ndv = mathutil.MaxInt64(ndv, coll.Columns[colID].NDV) |
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.
Why not use the col1.ndv * col2.ndv * ...
instead of max of them?
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.
If the 2 rows are like (1,1),(2,2), the NDV is 2 not 4. max
is lower bound, ndv * ndv
is upper bound, using max
is consistent with getCardinality()
.
Codecov Report
@@ Coverage Diff @@
## master #17366 +/- ##
===========================================
Coverage 80.0259% 80.0259%
===========================================
Files 521 521
Lines 141614 141614
===========================================
Hits 113328 113328
Misses 19266 19266
Partials 9020 9020 |
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.
LGTM
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.
LGTM
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
@eurekaka merge failed. |
Signed-off-by: sre-bot <sre-bot@pingcap.com>
cherry pick to release-3.0 in PR #17609 |
Signed-off-by: sre-bot <sre-bot@pingcap.com>
cherry pick to release-3.1 in PR #17610 |
Signed-off-by: sre-bot <sre-bot@pingcap.com>
cherry pick to release-4.0 in PR #17611 |
What problem does this PR solve?
Issue Number: close #17364
Problem Summary:
Wrong plan is chosen when index equal condition contains value which is out of the range of the histogram.
What is changed and how it works?
What's Changed:
Compute the NDV for the prefix columns of the index which are used for equal condition, and use it for row count guess.
How it Works:
It is more reasonable than hard-coded constant
outOfRangeBetweenRate
.Related changes
N/A
Check List
Tests
Side effects
N/A
Release note