-
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
ddl: speed up the operation of "create table" #6861
Conversation
/run-all-tests |
ddl/table.go
Outdated
@@ -130,19 +127,23 @@ func onDropTable(t *meta.Meta, job *model.Job) (ver int64, _ error) { | |||
return ver, errors.Trace(err) | |||
} | |||
|
|||
func splitTableRegion(store kv.Storage, tableID int64) error { | |||
type splitableStore interface { |
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 add it?
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.
I don't add it, I only move it from splitTableRegion
to 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.
But it still appears in splitTableRegion
.
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.
Should we remove the code at line 135~137?
ddl/table.go
Outdated
} | ||
tableStartKey := tablecodec.GenTablePrefix(tableID) | ||
if err := s.SplitRegion(tableStartKey); err != nil { | ||
return errors.Trace(err) | ||
// It will be automatically splitting by TiKV later. |
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.
s/splitting/splited/
PTAL @lamxTyler @shenli |
LGTM |
@winkyao @lamxTyler 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
What have you changed? (mandatory)
Handle table split operations asynchronously.
What are the type of the changes (mandatory)?
Does this PR affect documentation (docs/docs-cn) update? (optional)
No.
Benchmark result if necessary (optional)
Using TiKV
The test code as follows:
use the original code, the result as follows:
2018/05/18 17:37:16 tidb_create.go:35: [info] exec sql use db0
2018/05/18 17:41:09 tidb_create.go:44: [info] exec sqls take time 3m53.493631103s
2018/05/18 17:41:09 tidb_create.go:35: [info] exec sql use db1
2018/05/18 17:45:03 tidb_create.go:44: [info] exec sqls take time 3m53.914944715s
2018/05/18 17:45:03 tidb_create.go:35: [info] exec sql use db2
2018/05/18 17:48:57 tidb_create.go:44: [info] exec sqls take time 3m53.528751212s
2018/05/18 17:48:57 tidb_create.go:35: [info] exec sql use db3
2018/05/18 17:52:56 tidb_create.go:44: [info] exec sqls take time 3m59.223324563s
2018/05/18 17:52:56 tidb_create.go:35: [info] exec sql use db4
2018/05/18 17:56:56 tidb_create.go:44: [info] exec sqls take time 3m59.867498659s
2018/05/18 17:56:56 tidb_create.go:35: [info] exec sql use db5
2018/05/18 18:01:01 tidb_create.go:44: [info] exec sqls take time 4m5.327908179s
2018/05/18 18:01:01 tidb_create.go:35: [info] exec sql use db6
2018/05/18 18:05:09 tidb_create.go:44: [info] exec sqls take time 4m7.886515515s
2018/05/18 18:05:09 tidb_create.go:35: [info] exec sql use db7
2018/05/18 18:09:15 tidb_create.go:44: [info] exec sqls take time 4m5.60381973s
2018/05/18 18:09:15 tidb_create.go:35: [info] exec sql use db8
2018/05/18 18:13:32 tidb_create.go:44: [info] exec sqls take time 4m16.640030126s
use the new code, the result as follows:
2018/05/18 18:42:03 tidb_create.go:35: [info] exec sql use db0
2018/05/18 18:44:08 tidb_create.go:44: [info] exec sqls take time 2m4.89636175s
2018/05/18 18:44:08 tidb_create.go:35: [info] exec sql use db1
2018/05/18 18:46:14 tidb_create.go:44: [info] exec sqls take time 2m5.840172046s
2018/05/18 18:46:14 tidb_create.go:35: [info] exec sql use db2
2018/05/18 18:48:22 tidb_create.go:44: [info] exec sqls take time 2m7.847079946s
2018/05/18 18:48:22 tidb_create.go:35: [info] exec sql use db3
2018/05/18 18:50:32 tidb_create.go:44: [info] exec sqls take time 2m9.464254105s
2018/05/18 18:50:32 tidb_create.go:35: [info] exec sql use db4
2018/05/18 18:52:42 tidb_create.go:44: [info] exec sqls take time 2m10.56319663s
2018/05/18 18:52:43 tidb_create.go:35: [info] exec sql use db5
2018/05/18 18:54:57 tidb_create.go:44: [info] exec sqls take time 2m14.954220944s
2018/05/18 18:54:58 tidb_create.go:35: [info] exec sql use db6
2018/05/18 18:57:14 tidb_create.go:44: [info] exec sqls take time 2m16.526956612s
2018/05/18 18:57:14 tidb_create.go:35: [info] exec sql use db7
2018/05/18 18:59:33 tidb_create.go:44: [info] exec sqls take time 2m18.566134241s
2018/05/18 18:59:33 tidb_create.go:35: [info] exec sql use db8
2018/05/18 19:02:33 tidb_create.go:44: [info] exec sqls take time 3m0.43806444s