Skip to content
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

Merged

Conversation

lzmhhh123
Copy link
Contributor

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

  • Unit test
  • Integration test

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM

Release note

  • none

@lzmhhh123 lzmhhh123 added sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement. labels Jun 16, 2020
// Init commonHandleCols and commonHandleLens for data source.
if tableInfo.IsCommonHandle {
for _, idx := range tableInfo.Indices {
if idx.Primary {
Copy link
Member

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.

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 {
Copy link
Member

@coocood coocood Jun 16, 2020

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.

} else {
if len(is.IdxCols) < len(is.Columns) {
for i := len(is.IdxCols); i < len(idxExprCols); i++ {
indexCols = append(indexCols, idxExprCols[i])
Copy link
Member

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?

Copy link
Contributor Author

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.

@coocood coocood requested a review from eurekaka June 16, 2020 09:39
@github-actions github-actions bot added the sig/execution SIG execution label Jun 16, 2020
@codecov
Copy link

codecov bot commented Jun 16, 2020

Codecov Report

Merging #18054 into master will decrease coverage by 0.3446%.
The diff coverage is 100.0000%.

@@               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     

@lzmhhh123
Copy link
Contributor Author

/run-unit-test

@coocood
Copy link
Member

coocood commented Jun 16, 2020

/run-unit-test

1 similar comment
@coocood
Copy link
Member

coocood commented Jun 16, 2020

/run-unit-test

@coocood coocood requested a review from wjhuang2016 June 17, 2020 03:53
@lzmhhh123
Copy link
Contributor Author

/run-check_dev

Copy link
Member

@wjhuang2016 wjhuang2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@coocood coocood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lzmhhh123 lzmhhh123 added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. labels Jun 17, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@lzmhhh123 merge failed.

@lzmhhh123 lzmhhh123 merged commit 463d085 into pingcap:master Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants