-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: split index region with lower upper syntax #10409
Conversation
/run-all-tests |
1 similar comment
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #10409 +/- ##
===============================================
- Coverage 79.5733% 79.568% -0.0054%
===============================================
Files 415 415
Lines 87993 88112 +119
===============================================
+ Hits 70019 70109 +90
- Misses 12793 12813 +20
- Partials 5181 5190 +9 |
/run-all-tests |
…into split_index_step
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 |
if err != nil { | ||
return nil, err | ||
} | ||
upperIdxKey, _, err := index.GenIndexKey(e.ctx.GetSessionVars().StmtCtx, e.upper, math.MinInt64, 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.
Why we don't usemath.MaxInt64
? Please add comments.
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.
Sound reasonable, But I just want to keep consistent with lowerIdxKey
here ,I don't like the result of (maxHandleID - minHandleID) != 0
to affect the split point. Use math.MaxInt64
here will get error from TestSplitIndex
.
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.
Already add a comment here.
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 |
planner/core/planbuilder.go
Outdated
return nil, ErrWrongValueCountOnRow.GenWithStackByArgs(i + 1) | ||
} | ||
valueList := make([]types.Datum, 0, len(valuesItem)) | ||
convertValue2ColumnType := func(valuesItem []ast.ExprNode) ([]types.Datum, error) { |
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 you split this function outside the definition of buildSplitRegion()
? It's a complicated function with 40 lines, which reduces the readability of buildSplitRegion()
/run-all-tests |
What problem does this PR solve?
Add new syntax for
split index region
.SPLIT TABLE [table_name] INDEX [index_name] BETWEEN (lower_value...) AND (upper_value...) REGIONS [region_num]
Attention
lower_value
andupper_value
value count should less than the index column num.lower_value
andupper_value
value count should more than 0.1000
.Eg1: int type.
Upper sql will split
5
regions of the tablet
indexidx1
in range0~1000
. Every region range like below:Region1: -inf ~ 200
Region2: 200 ~ 400
Region3: 400 ~ 600
Region4: 600 ~ 800
Region5: 800 ~ +inf
Eg2: varchar type
Upper sql will split
26
regions.Region1: -inf ~ b
Region2: b ~ c
...
Region26: y ~ +inf
Eg3: time type.
Upper sql will split
10
regions.Region1: -inf ~ 2011-01-01 00:00:00
Region2: 2011-01-01 00:00:00 ~ 2012-01-01 00:00:00
...
Region10: 2011-01-01 00:00:00 ~ +inf
**Eg4: multi-column index.
idx1 (col1,col2,col3)
. **if you only want to split index region by first column
col1
. You can use SQL like Eg1,Eg2,Eg3. Suppose col1 is int type.If you wanto split index regions by first two column. You can use SQL like below.
What is changed and how it works?
Related Parser PR: pingcap/parser#321
Split
num
regions betweenlower
andupper
value.Because the key value is byte slice, I cann't do this simple like
(max-min) / num
.To solve this problem:
0xff
diff_uint64/num
to get thestep
value.Check List
Tests
Code changes
Side effects
Related changes