From c056576ddf29bc83a4b11d9cf0dd2cda6acc4878 Mon Sep 17 00:00:00 2001 From: Rustin170506 Date: Thu, 9 Jan 2025 16:00:58 +0800 Subject: [PATCH] statistics: refine table filtering in analysis job creation to exclude memory and system databases Signed-off-by: Rustin170506 --- pkg/statistics/handle/autoanalyze/priorityqueue/queue.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/statistics/handle/autoanalyze/priorityqueue/queue.go b/pkg/statistics/handle/autoanalyze/priorityqueue/queue.go index 93a95bd4b43cc..fa17574d4034c 100644 --- a/pkg/statistics/handle/autoanalyze/priorityqueue/queue.go +++ b/pkg/statistics/handle/autoanalyze/priorityqueue/queue.go @@ -221,13 +221,15 @@ func (pq *AnalysisPriorityQueue) fetchAllTablesAndBuildAnalysisJobs() error { jobFactory := NewAnalysisJobFactory(sctx, autoAnalyzeRatio, currentTs) snapshot := sctx.GetStore().GetSnapshot(kv.NewVersion(currentTs)) + is := sctx.GetDomainInfoSchema().(infoschema.InfoSchema) m := meta.NewReader(snapshot) tbls := make([]*model.TableInfo, 0, 1024) if err := m.IterAllTables(func(info *model.TableInfo) error { // Ignore the memory and system database. - // if util.IsMemOrSysDB(db.L) { - // continue - // } + db, ok := is.SchemaByID(info.DBID) + if !ok || util.IsMemOrSysDB(db.Name.L) { + return nil + } tbls = append(tbls, info) return nil }); err != nil {