Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions pkg/statistics/handle/autoanalyze/refresher/refresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package refresher

import (
"strings"
"time"

"github.com/pingcap/tidb/pkg/infoschema"
Expand Down Expand Up @@ -169,19 +168,19 @@ func (r *Refresher) RebuildTableAnalysisJobQueue() error {
return err
}

dbs := infoschema.AllSchemaNames(is)
dbs := is.AllSchemaNames()
for _, db := range dbs {
// Sometimes the tables are too many. Auto-analyze will take too much time on it.
// so we need to check the available time.
if !r.autoAnalysisTimeWindow.isWithinTimeWindow(time.Now()) {
return nil
}
// Ignore the memory and system database.
if util.IsMemOrSysDB(strings.ToLower(db)) {
if util.IsMemOrSysDB(db.L) {
continue
}

tbls := is.SchemaTables(model.NewCIStr(db))
tbls := is.SchemaTables(db)
// We need to check every partition of every table to see if it needs to be analyzed.
for _, tbl := range tbls {
// If table locked, skip analyze all partitions of the table.
Expand Down Expand Up @@ -217,7 +216,7 @@ func (r *Refresher) RebuildTableAnalysisJobQueue() error {
if pi == nil {
job := CreateTableAnalysisJob(
sctx,
db,
db.O,
tblInfo,
r.statsHandle.GetTableStatsForAutoAnalyze(tblInfo),
autoAnalyzeRatio,
Expand All @@ -241,7 +240,7 @@ func (r *Refresher) RebuildTableAnalysisJobQueue() error {
for pIDAndName, stats := range partitionStats {
job := CreateStaticPartitionAnalysisJob(
sctx,
db,
db.O,
tblInfo,
pIDAndName.ID,
pIDAndName.Name,
Expand All @@ -254,7 +253,7 @@ func (r *Refresher) RebuildTableAnalysisJobQueue() error {
} else {
job := createTableAnalysisJobForPartitions(
sctx,
db,
db.O,
tblInfo,
r.statsHandle.GetPartitionStatsForAutoAnalyze(tblInfo, tblInfo.ID),
partitionStats,
Expand Down