-
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: check clustered index don't need double read #18054
planner: check clustered index don't need double read #18054
Conversation
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 { |
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.
There is a function tables.FindPrimaryIndex
can be used.
planner/core/find_best_task.go
Outdated
continue | ||
} | ||
if col.ID == model.ExtraHandleID { | ||
continue | ||
} | ||
isIndexColumn := false | ||
for i, indexCol := range indexColumns { | ||
isFullLen := idxColLens[i] == types.UnspecifiedLength || idxColLens[i] == col.RetType.Flen | ||
for i, indexCol := range indexCols { |
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.
We can extract this for loop, and call it twice with indexColumns
and commonHandleCols
.
So we don't need to append slices.
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]) |
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.
Need to check if idxExprCols[i] != nil
?
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.
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 |
/run-unit-test |
/run-unit-test |
1 similar comment
/run-unit-test |
/run-check_dev |
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
/run-all-tests |
@lzmhhh123 merge failed. |
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