-
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
*: make analyze buckets number configurable #7619
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,6 +434,7 @@ import ( | |
|
||
/* The following tokens belong to TiDBKeyword. */ | ||
admin "ADMIN" | ||
buckets "BUCKETS" | ||
cancel "CANCEL" | ||
ddl "DDL" | ||
jobs "JOBS" | ||
|
@@ -666,6 +667,7 @@ import ( | |
LinesTerminated "Lines terminated by" | ||
LocalOpt "Local opt" | ||
LockClause "Alter table lock clause" | ||
MaxNumBuckets "Max number of buckets" | ||
NumLiteral "Num/Int/Float/Decimal Literal" | ||
NoWriteToBinLogAliasOpt "NO_WRITE_TO_BINLOG alias LOCAL or empty" | ||
ObjectType "Grant statement object type" | ||
|
@@ -1225,14 +1227,23 @@ TableToTable: | |
/*******************************************************************************************/ | ||
|
||
AnalyzeTableStmt: | ||
"ANALYZE" "TABLE" TableNameList | ||
"ANALYZE" "TABLE" TableNameList MaxNumBuckets | ||
{ | ||
$$ = &ast.AnalyzeTableStmt{TableNames: $3.([]*ast.TableName)} | ||
$$ = &ast.AnalyzeTableStmt{TableNames: $3.([]*ast.TableName), MaxNumBuckets: $4.(uint64)} | ||
} | ||
| "ANALYZE" "TABLE" TableName "INDEX" IndexNameList | ||
{ | ||
$$ = &ast.AnalyzeTableStmt{TableNames: []*ast.TableName{$3.(*ast.TableName)}, IndexNames: $5.([]model.CIStr), IndexFlag: true} | ||
} | ||
| "ANALYZE" "TABLE" TableName "INDEX" IndexNameList MaxNumBuckets | ||
{ | ||
$$ = &ast.AnalyzeTableStmt{TableNames: []*ast.TableName{$3.(*ast.TableName)}, IndexNames: $5.([]model.CIStr), IndexFlag: true, MaxNumBuckets: $6.(uint64)} | ||
} | ||
|
||
MaxNumBuckets: | ||
{ | ||
$$ = uint64(0) | ||
} | ||
| "LIMIT" NUM "BUCKETS" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about change the syntax to maybe we can lean from mysql: https://dev.mysql.com/doc/refman/8.0/en/analyze-table.html |
||
{ | ||
$$ = getUint64FromNUM($2) | ||
} | ||
|
||
/*******************************************************************************************/ | ||
Assignment: | ||
|
@@ -2809,7 +2820,7 @@ UnReservedKeyword: | |
|
||
|
||
TiDBKeyword: | ||
"ADMIN" | "CANCEL" | "DDL" | "JOBS" | "JOB" | "STATS" | "STATS_META" | "STATS_HISTOGRAMS" | "STATS_BUCKETS" | "STATS_HEALTHY" | "TIDB" | "TIDB_HJ" | "TIDB_SMJ" | "TIDB_INLJ" | ||
"ADMIN" | "BUCKETS" | "CANCEL" | "DDL" | "JOBS" | "JOB" | "STATS" | "STATS_META" | "STATS_HISTOGRAMS" | "STATS_BUCKETS" | "STATS_HEALTHY" | "TIDB" | "TIDB_HJ" | "TIDB_SMJ" | "TIDB_INLJ" | ||
|
||
NotKeywordToken: | ||
"ADDDATE" | "BIT_AND" | "BIT_OR" | "BIT_XOR" | "CAST" | "COPY" | "COUNT" | "CURTIME" | "DATE_ADD" | "DATE_SUB" | "EXTRACT" | "GET_FORMAT" | "GROUP_CONCAT" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import ( | |
|
||
. "github.com/pingcap/check" | ||
"github.com/pingcap/tidb/domain" | ||
"github.com/pingcap/tidb/executor" | ||
"github.com/pingcap/tidb/kv" | ||
"github.com/pingcap/tidb/model" | ||
"github.com/pingcap/tidb/mysql" | ||
|
@@ -868,17 +867,14 @@ func (s *testStatsUpdateSuite) TestLogDetailedInfo(c *C) { | |
oriMinLogCount := statistics.MinLogScanCount | ||
oriMinError := statistics.MinLogErrorRate | ||
oriLevel := log.GetLevel() | ||
oriBucketNum := executor.GetMaxBucketSizeForTest() | ||
oriLease := s.do.StatsHandle().Lease | ||
defer func() { | ||
statistics.FeedbackProbability = oriProbability | ||
statistics.MinLogScanCount = oriMinLogCount | ||
statistics.MinLogErrorRate = oriMinError | ||
executor.SetMaxBucketSizeForTest(oriBucketNum) | ||
s.do.StatsHandle().Lease = oriLease | ||
log.SetLevel(oriLevel) | ||
}() | ||
executor.SetMaxBucketSizeForTest(4) | ||
statistics.FeedbackProbability = 1 | ||
statistics.MinLogScanCount = 0 | ||
statistics.MinLogErrorRate = 0 | ||
|
@@ -890,7 +886,7 @@ func (s *testStatsUpdateSuite) TestLogDetailedInfo(c *C) { | |
for i := 0; i < 20; i++ { | ||
testKit.MustExec(fmt.Sprintf("insert into t values (%d, %d, %d)", i, i, i)) | ||
} | ||
testKit.MustExec("analyze table t") | ||
testKit.MustExec("analyze table t limit 4 buckets") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why use 4 buckets here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is the test's requirement. Each bucket should contain more than 1 values. |
||
tests := []struct { | ||
sql string | ||
result string | ||
|
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.
IMHO, it's better to more this validation to the parser or planner.