-
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
*: add split index region syntax #10203
Conversation
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
executor/split.go
Outdated
regionIDs := make([]uint64, 0, len(e.valueLists)) | ||
index := tables.NewIndex(e.table.Meta().ID, e.table.Meta(), e.indexInfo) | ||
for _, values := range e.valueLists { | ||
idxKey, _, err := index.GenIndexKey(e.ctx.GetSessionVars().StmtCtx, values, 1, 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.
1
means min handle id?
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.
yes, Maybe 0
is better?
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.
you can use a constant, better than hard code!
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.
@winkyao
I think 1
isn't always the min handle. If a table has a PKIsHandle column, then the handle may be a negative value.
So I think we need to use math.MinInt64
.
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 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.
Here is a test:
0 encode to byte is: [128 0 0 0 0 0 0 0]
math.MinInt64 encode to byte is: [0 0 0 0 0 0 0 0]
so, math.MinInt64 is better.
Codecov Report
@@ Coverage Diff @@
## master #10203 +/- ##
================================================
- Coverage 77.6772% 77.6566% -0.0206%
================================================
Files 411 412 +1
Lines 85460 85511 +51
================================================
+ Hits 66383 66405 +22
- Misses 14119 14141 +22
- Partials 4958 4965 +7 |
planner/core/planbuilder.go
Outdated
for j, valueItem := range valuesItem { | ||
x, ok := valueItem.(*driver.ValueExpr) | ||
if !ok { | ||
return nil, errors.Trace(errors.New("expect constant values")) |
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.
Could we remove this trace
? Other places don't use it.
And we can print the value to the error message.
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.
done.
executor/split.go
Outdated
regionIDs := make([]uint64, 0, len(e.valueLists)) | ||
index := tables.NewIndex(e.table.Meta().ID, e.table.Meta(), e.indexInfo) | ||
for _, values := range e.valueLists { | ||
idxKey, _, err := index.GenIndexKey(e.ctx.GetSessionVars().StmtCtx, values, 1, 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.
@winkyao
I think 1
isn't always the min handle. If a table has a PKIsHandle column, then the handle may be a negative value.
So I think we need to use math.MinInt64
.
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
err := s.WaitScatterRegionFinish(regionID) | ||
if err != nil { | ||
logutil.Logger(context.Background()).Warn("wait scatter region failed", | ||
zap.Uint64("regionID", regionID), |
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.
Do we need to add the table and index information to this log?
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.
done.
/run-all-tests |
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
What problem does this PR solve?
PR: #10138 support pre-split table region. But it will only split 1 region for per index. Then the index region may still be the hot region and the write bottleneck.
What is changed and how it works?
This PR support split index region by SQL. Syntax like below:
example
Please merge #10138 firstly.
Related parser PR: pingcap/parser#297
Check List
Tests
Code changes
Side effects
Related changes