-
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
statistics: enables global-level stats to be generated in fast analyze mode #22931
Changes from 5 commits
089124e
adc8c9a
a0fce3a
be6f8f9
8e42276
50d7396
b26ada9
6c21108
6d62124
fb1c048
6d4ce46
9517465
93218c1
0b720c9
70e5bee
66d62ef
352fa6e
b7a2501
f7de949
5f31eba
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 |
---|---|---|
|
@@ -171,6 +171,12 @@ func (e *AnalyzeExec) Next(ctx context.Context, req *chunk.Chunk) error { | |
sc := e.ctx.GetSessionVars().StmtCtx | ||
globalStats, err := statsHandle.MergePartitionStats2GlobalStats(sc, infoschema.GetInfoSchema(e.ctx), globalStatsID.tableID, info.isIndex, info.idxID) | ||
if err != nil { | ||
errMessage := err.Error() | ||
if errMessage == "[stats] build global-level stats failed due to missing partition-level stats" { | ||
// When we find some partition-level stats are missing, we need to report warning. | ||
sc.AppendWarning(err) | ||
continue | ||
} | ||
return err | ||
} | ||
for i := 0; i < globalStats.Num; i++ { | ||
|
@@ -809,8 +815,7 @@ func (e *AnalyzeFastExec) calculateEstimateSampleStep() (err error) { | |
sql := new(strings.Builder) | ||
sqlexec.MustFormatSQL(sql, "select count(*) from %n.%n", dbInfo.Name.L, e.tblInfo.Name.L) | ||
|
||
pruneMode := variable.PartitionPruneMode(e.ctx.GetSessionVars().PartitionPruneMode.Load()) | ||
if pruneMode != variable.DynamicOnly && e.tblInfo.ID != e.tableID.GetStatisticsID() { | ||
if e.tblInfo.ID != e.tableID.GetStatisticsID() { | ||
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 don't we check 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. The |
||
for _, definition := range e.tblInfo.Partition.Definitions { | ||
if definition.ID == e.tableID.GetStatisticsID() { | ||
sqlexec.MustFormatSQL(sql, " partition(%n)", definition.Name.L) | ||
|
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.
Judging an error by comparing its error message is dangerous.
You'd better create a new kind of error and use
errors.Cause(err)
.Here is an example: