-
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
planner: improve row count estimation of IndexJoin's inner scan #12085
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12085 +/- ##
===========================================
Coverage ? 81.3048%
===========================================
Files ? 452
Lines ? 96886
Branches ? 0
===========================================
Hits ? 78773
Misses ? 12460
Partials ? 5653 |
/run-all-tests |
/run-all-tests |
/run-unit-test |
70c5082
to
a500ba5
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.
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
a500ba5
to
23e5b8b
Compare
/bench |
@@ Benchmark Diff @@
================================================================================
--- tidb: 5c18c5df97d935398ea1b44098a0db3171999466
+++ tidb: 7278ab07104a307f04e72e21d02f6528f8591013
tikv: ff82aa9eba331585aec1c6cdf9e1584512bccb34
pd: ce060a9aeb66d6bbb39159243b879740dffae041
================================================================================
test-1: < oltp_insert >
* QPS : 21141.44 ± 1.5888% (std=240.80) delta: -0.08%
* AvgMs : 12.10 ± 1.6193% (std=0.14) delta: 0.08%
* PercentileMs99 : 42.92 ± 1.0903% (std=0.38) delta: 1.46%
test-2: < oltp_update_non_index >
* QPS : 29436.80 ± 0.2322% (std=47.10) delta: -0.10%
* AvgMs : 8.69 ± 0.2071% (std=0.01) delta: 0.09%
* PercentileMs99 : 30.59 ± 1.0788% (std=0.27) delta: 1.09%
test-3: < oltp_read_write >
* QPS : 37051.41 ± 0.3770% (std=80.95) delta: 0.32%
* AvgMs : 138.73 ± 0.3792% (std=0.31) delta: -0.32%
* PercentileMs99 : 257.95 ± 0.0000% (std=0.00) delta: 0.00%
test-4: < oltp_point_select >
* QPS : 74734.42 ± 3.2705% (std=1572.71) delta: -0.30%
* AvgMs : 3.43 ± 3.0940% (std=0.07) delta: 0.40%
* PercentileMs99 : 7.43 ± 0.0000% (std=0.00) delta: 0.00%
test-5: < oltp_update_index >
* QPS : 16880.32 ± 0.5051% (std=62.94) delta: 0.29%
* AvgMs : 15.16 ± 0.5012% (std=0.06) delta: -0.29%
* PercentileMs99 : 48.34 ± 0.0000% (std=0.00) delta: 0.00%
|
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
Please resolve the conflicts.
7278ab0
to
048da9c
Compare
Your auto merge job has been accepted, waiting for 12009 |
/run-all-tests |
What problem does this PR solve?
Currently, the row count estimation of IndexJoin's inner child is not that accurate because:
Count / NDV
, if the index used is composite index, and the join key only covers the prefix of the index, the row count would be smaller than the real countWhat is changed and how it works?
Initially, I considered comparing histograms of both child plans to compute an overlapping ratio and using it for row count estimation, but found that it was trivial to handle the mismatch between the data types, and it was hard to compute overlap for composite index cases.
Alternatively, I choose to reuse the estimated row count of join result after evaluating join equal conditions, because
leftCnt * rightCnt / max(leftNDV, rightNDV)
has already taken the overlap into account more or less, and this approach can give more consistent row count estimations for join operator and its children.Check List
Tests
Code changes
N/A
Side effects
Related changes
N/A
Release note