From f0eafeb8cdb254050eaaa17284e4ce30a9b7a295 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 27 May 2024 13:35:51 +0800 Subject: [PATCH] statistics: print the process of init stats Signed-off-by: Weizhen Wang --- pkg/executor/analyze_global_stats.go | 5 ----- pkg/statistics/handle/globalstats/global_stats.go | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/executor/analyze_global_stats.go b/pkg/executor/analyze_global_stats.go index 85a1be1113099..97e211458535e 100644 --- a/pkg/executor/analyze_global_stats.go +++ b/pkg/executor/analyze_global_stats.go @@ -21,7 +21,6 @@ import ( "github.com/pingcap/tidb/pkg/infoschema" "github.com/pingcap/tidb/pkg/statistics" statstypes "github.com/pingcap/tidb/pkg/statistics/handle/types" - "github.com/pingcap/tidb/pkg/types" "github.com/pingcap/tidb/pkg/util/logutil" "go.uber.org/zap" ) @@ -76,10 +75,6 @@ func (e *AnalyzeExec) handleGlobalStats(globalStatsMap globalStatsMap) error { if err != nil { logutil.BgLogger().Warn("merge global stats failed", zap.String("info", job.JobInfo), zap.Error(err), zap.Int64("tableID", tableID)) - if types.ErrPartitionStatsMissing.Equal(err) || types.ErrPartitionColumnStatsMissing.Equal(err) { - // When we find some partition-level stats are missing, we need to report warning. - e.Ctx().GetSessionVars().StmtCtx.AppendWarning(err) - } return err } return nil diff --git a/pkg/statistics/handle/globalstats/global_stats.go b/pkg/statistics/handle/globalstats/global_stats.go index a48e73858d479..1305a6c801bdb 100644 --- a/pkg/statistics/handle/globalstats/global_stats.go +++ b/pkg/statistics/handle/globalstats/global_stats.go @@ -55,6 +55,10 @@ func (sg *statsGlobalImpl) MergePartitionStats2GlobalStatsByTableID(sc sessionct ) (err error) { globalStats, err := MergePartitionStats2GlobalStatsByTableID(sc, sg.statsHandler, opts, is, physicalID, isIndex, histIDs) if err != nil { + if types.ErrPartitionStatsMissing.Equal(err) || types.ErrPartitionColumnStatsMissing.Equal(err) { + // When we find some partition-level stats are missing, we need to report warning. + sc.GetSessionVars().StmtCtx.AppendWarning(err) + } return nil } return WriteGlobalStatsToStorage(sg.statsHandler, globalStats, info, physicalID)