planner: check clustered index don't need double read#18054
Merged
lzmhhh123 merged 9 commits intopingcap:masterfrom Jun 17, 2020
Merged
planner: check clustered index don't need double read#18054lzmhhh123 merged 9 commits intopingcap:masterfrom
lzmhhh123 merged 9 commits intopingcap:masterfrom
Conversation
coocood
reviewed
Jun 16, 2020
planner/core/logical_plan_builder.go
Outdated
| // Init commonHandleCols and commonHandleLens for data source. | ||
| if tableInfo.IsCommonHandle { | ||
| for _, idx := range tableInfo.Indices { | ||
| if idx.Primary { |
Member
There was a problem hiding this comment.
There is a function tables.FindPrimaryIndex can be used.
coocood
reviewed
Jun 16, 2020
planner/core/find_best_task.go
Outdated
| isIndexColumn := false | ||
| for i, indexCol := range indexColumns { | ||
| isFullLen := idxColLens[i] == types.UnspecifiedLength || idxColLens[i] == col.RetType.Flen | ||
| for i, indexCol := range indexCols { |
Member
There was a problem hiding this comment.
We can extract this for loop, and call it twice with indexColumns and commonHandleCols.
So we don't need to append slices.
coocood
reviewed
Jun 16, 2020
planner/core/find_best_task.go
Outdated
| } else { | ||
| if len(is.IdxCols) < len(is.Columns) { | ||
| for i := len(is.IdxCols); i < len(idxExprCols); i++ { | ||
| indexCols = append(indexCols, idxExprCols[i]) |
Member
There was a problem hiding this comment.
Need to check if idxExprCols[i] != nil?
Contributor
Author
There was a problem hiding this comment.
idxExprCols here for common handle never be nil.
Codecov Report
@@ Coverage Diff @@
## master #18054 +/- ##
================================================
- Coverage 79.7721% 79.4275% -0.3447%
================================================
Files 526 524 -2
Lines 145913 142200 -3713
================================================
- Hits 116398 112946 -3452
+ Misses 20187 20104 -83
+ Partials 9328 9150 -178 |
Contributor
Author
|
/run-unit-test |
Member
|
/run-unit-test |
1 similar comment
Member
|
/run-unit-test |
Contributor
Author
|
/run-check_dev |
Contributor
|
/run-all-tests |
Contributor
|
@lzmhhh123 merge failed. |
12 tasks
This was referenced Feb 12, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Problem Summary: as the title says.
What is changed and how it works?
What's Changed: check clustered index don't need double read
Check List
Tests
Side effects
Release note