-
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
executor: support index merge on cluster index #18699
executor: support index merge on cluster index #18699
Conversation
…github.com/lzmhhh123/tidb into dev/support_clustered_index_in_index_merge
…github.com/lzmhhh123/tidb into dev/support_clustered_index_in_index_merge
@@ -2681,6 +2681,10 @@ func (b *executorBuilder) buildIndexMergeReader(v *plannercore.PhysicalIndexMerg | |||
sctx.IndexNames = append(sctx.IndexNames, is.Table.Name.O+":"+is.Index.Name.O) | |||
} else { | |||
ret.ranges = append(ret.ranges, v.PartialPlans[i][0].(*plannercore.PhysicalTableScan).Ranges) | |||
if ret.table.Meta().IsCommonHandle { | |||
tblInfo := ret.table.Meta() | |||
sctx.IndexNames = append(sctx.IndexNames, tblInfo.Name.O+":"+tables.FindPrimaryIndex(tblInfo).Name.O) |
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 simply use 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.
It keeps the same name as the unclustered primary key.
executor/index_merge_reader.go
Outdated
@@ -359,8 +383,11 @@ func (w *partialTableWorker) extractTaskHandles(ctx context.Context, chk *chunk. | |||
return handles, retChk, nil | |||
} | |||
for i := 0; i < chk.NumRows(); i++ { | |||
h := kv.IntHandle(chk.GetRow(i).GetInt64(handleOffset)) | |||
handles = append(handles, h) | |||
handle, err := handleCols.BuildHandleByOffsets(chk.GetRow(i), handleOffset) |
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 handleCols has resolved column index, can we call BuildHandle
without handleOffset
?
executor/index_merge_reader.go
Outdated
handleOffset := chk.NumCols() - 1 | ||
var handleOffset []int | ||
for i := 0; i < handleCols.NumCols(); i++ { | ||
handleOffset = append(handleOffset, chk.NumCols()-handleCols.NumCols()+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.
Since the index row's handle columns always at the last, we can move this logic into HandleCols
, and use a method BuildHandleFromIndexRow
.
We don't need to build the handleOffsets.
/rebuild |
LGTM |
@eurekaka PTAL |
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
/merge |
/run-all-tests |
@lzmhhh123 merge failed. |
Codecov Report
@@ Coverage Diff @@
## master #18699 +/- ##
================================================
+ Coverage 79.2262% 79.7364% +0.5102%
================================================
Files 542 544 +2
Lines 146189 149870 +3681
================================================
+ Hits 115820 119501 +3681
+ Misses 21034 21025 -9
- Partials 9335 9344 +9 |
/merge |
/run-all-tests |
/run-all-tests |
What problem does this PR solve?
Problem Summary: as title says.
What is changed and how it works?
What's Changed: support index merge on cluster index
Related changes
Check List
Tests
Side effects
Release note