-
Notifications
You must be signed in to change notification settings - Fork 5.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
planner: generate physical plan for IndexMergePath #11245
Conversation
Codecov Report
@@ Coverage Diff @@
## master #11245 +/- ##
===========================================
Coverage ? 81.1477%
===========================================
Files ? 423
Lines ? 90249
Branches ? 0
===========================================
Hits ? 73235
Misses ? 11714
Partials ? 5300 |
Codecov Report
@@ Coverage Diff @@
## master #11245 +/- ##
===========================================
Coverage 81.4765% 81.4765%
===========================================
Files 453 453
Lines 98216 98216
===========================================
Hits 80023 80023
Misses 12528 12528
Partials 5665 5665 |
@eurekaka This the first version for generating physical plan for |
Hi contributor, thanks for your PR. This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically. |
/ok-to-test |
planner/core/task.go
Outdated
totalRowCount += partPlan.StatsCount() | ||
} | ||
p.stats = property.NewSimpleStats(totalRowCount) | ||
p.stats.StatsVersion = t.idxMergePartPlans[0].statsInfo().StatsVersion |
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.
How about using t.idxMergePartPlans[0].statsInfo().Scale()
to keep the NDV of the stats info? Also, we can put the stats assignment into Init
as well?
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.
Can we put the stats assignment into Init
as well?
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.
The code is almost fine for me, except for those trivial commented problems. Please add tests for this PR, thanks.
planner/core/find_best_task.go
Outdated
} | ||
cop.idxMergePartPlans = scans | ||
cop.cst = totalCost | ||
task = cop |
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.
Please remove this line.
return ts, partialCost, rowCount, true | ||
} | ||
|
||
func (ds *DataSource) buildIndexMergeTableScan(prop *property.PhysicalProperty, tableFilters []expression.Expression, totalRowCount float64) (PhysicalPlan, float64) { |
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.
This function shares a lot of code with convertToPartialTableScan
, can we extract a common utility function for reuse?
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.
And also with convertToTableScan
, convertToPartialIndexScan
, it is better to use small functions that can compose rather than long and repeated codes.
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.
PTAL @hailanwhu
planner/core/task.go
Outdated
totalRowCount += partPlan.StatsCount() | ||
} | ||
p.stats = property.NewSimpleStats(totalRowCount) | ||
p.stats.StatsVersion = t.idxMergePartPlans[0].statsInfo().StatsVersion |
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.
Can we put the stats assignment into Init
as well?
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.
Can you add some test?
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 is the stats json file containing so many lines? should it be only one line?
planner/core/logical_plans.go
Outdated
@@ -593,7 +595,11 @@ func (ds *DataSource) deriveIndexPathStats(path *accessPath, conds []expression. | |||
logutil.BgLogger().Debug("calculate selectivity failed, use selection factor", zap.Error(err)) | |||
selectivity = selectionFactor | |||
} | |||
path.countAfterIndex = math.Max(path.countAfterAccess*selectivity, ds.stats.RowCount) | |||
if isIm { | |||
path.countAfterAccess = path.countAfterAccess * selectivity |
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 change the countAfterAccess
?
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.
sorry, it should be countAfterIndex
.
temporary implement of generate IndexMergePlan add functions to generate partial scans refactor some code refactor convertToIndexMergeScan fix comments (p PhysicalIndexMergeReader) Init(): p.schema fix comments temp delete the comment of convertToPartialIndexScan function add test for indexmerge; implement explain; fix some bugs temp explian-text
/rebuild |
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 12164, 12083, 12055 |
/run-all-tests |
What problem does this PR solve?
Fix #11113.
What is changed and how it works?
When meeting the
IndexMergePath
in(ds *DataSource) findBestTask
, it will call functionconvertToIndexMergeScan()
to generate the physical plan for the path.Check List
Tests
Code changes
Add
convertToIndexMergeScan()
andgetIndexMergeCandidate()
inplanner/core/find_best_task.go
.Modify some codes in
(ds *DataSource) findBestTask
andskylinePruning()
, and some related functions forcopTask
.Add
PhysicalIndexMergeReader
to present the physical plan forIndexMergePath
.Side effects
Related changes