-
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
Conversation
2919ae4
to
541efe8
Compare
/run-all-tests |
2.make fast analyze work in dynamic mode
1395565
to
8e42276
Compare
executor/analyze.go
Outdated
@@ -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" { |
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:
if _, ok := errors.Cause(err).(*tikv.PDError); !ok {
break
}
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we check PartitionPruneMode
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.
The AnalyzeFastExec
structure is based on partition. The content recorded in it corresponds to the content of the partition, not the whole table.
@qw4990: Please use If you have approved this PR, please ignore this reply. This reply is being used as a temporary reply during the migration of the new bot and will be removed on April 1. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
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
/merge |
@Reminiscent: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@Reminiscent: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
…lyze � Conflicts: � executor/analyze.go � executor/analyze_test.go � planner/core/planbuilder.go
/merge |
@Reminiscent: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@Reminiscent: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/run-tics-test |
/run-integration-common-test |
/merge |
@Reminiscent: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@Reminiscent: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/merge |
@qw4990: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
@qw4990: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
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?
sub PR for #22554
Problem Summary:
fast analyze mode
.globalStats.Count
.What is changed and how it works?
Same as described above.
Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note