Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions pkg/statistics/handle/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ func (*Handle) initStatsHistograms4ChunkLite(cache statstypes.StatsCache, iter *
table.LastAnalyzeVersion = max(table.LastAnalyzeVersion, row.GetUint64(4))
}
} else {
statslogutil.StatsLogger().Info("stat cache map insert col 2",
zap.Int64("tableID", table.PhysicalID),
zap.Int64("colID", id))
table.ColAndIdxExistenceMap.InsertCol(id, statsVer != statistics.Version0 || ndv > 0 || nullCount > 0)
if statsVer != statistics.Version0 {
// The LastAnalyzeVersion is added by ALTER table so its value might be 0.
Expand Down Expand Up @@ -267,6 +270,9 @@ func (h *Handle) initStatsHistograms4Chunk(is infoschema.InfoSchema, cache stats
StatsVer: statsVer,
}
table.SetCol(hist.ID, col)
statslogutil.StatsLogger().Info("stat cache map insert col 3",
zap.Int64("tableID", table.PhysicalID),
zap.Int64("colID", colInfo.ID))
table.ColAndIdxExistenceMap.InsertCol(colInfo.ID, statsVer != statistics.Version0 || ndv > 0 || nullCount > 0)
if statsVer != statistics.Version0 {
// The LastAnalyzeVersion is added by ALTER table so its value might be 0.
Expand Down
3 changes: 3 additions & 0 deletions pkg/statistics/handle/cache/statscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ func (s *StatsCacheImpl) Get(tableID int64) (*statistics.Table, bool) {

// Put puts this table stats into the cache.
func (s *StatsCacheImpl) Put(id int64, t *statistics.Table) {
statslogutil.StatsLogger().Info("stat cache put",
zap.Int64("tableID", id),
zap.Int("column number", t.ColNum()))
s.Load().put(id, t)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/statistics/handle/storage/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ func columnStatsFromStorage(sctx sessionctx.Context, row chunk.Row, table *stati
if histID != colInfo.ID {
continue
}
statslogutil.StatsLogger().Info("stat cache map insert col 4",
zap.Int64("tableID", table.PhysicalID),
zap.Int64("colID", histID))
table.ColAndIdxExistenceMap.InsertCol(histID, statsVer != statistics.Version0 || distinct > 0 || nullCount > 0)
// All the objects in the table shares the same stats version.
// Update here.
Expand Down
6 changes: 6 additions & 0 deletions pkg/statistics/handle/syncload/stats_syncload.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,19 @@ func (s *statsSyncLoad) updateCachedItem(item model.TableItemID, colHist *statis

// If the column is analyzed we refresh the map for the possible change.
if colHist.StatsAvailable() {
statslogutil.StatsLogger().Info("stat cache map insert col 5",
zap.Int64("tableID", tbl.PhysicalID),
zap.Int64("colID", item.ID))
tbl.ColAndIdxExistenceMap.InsertCol(item.ID, true)
}
// All the objects shares the same stats version. Update it here.
if colHist.StatsVer != statistics.Version0 {
tbl.StatsVer = statistics.Version0
}
// we have to refresh the map for the possible change to ensure that the map information is not missing.
statslogutil.StatsLogger().Info("stat cache map insert col 6",
zap.Int64("tableID", tbl.PhysicalID),
zap.Int64("colID", item.ID))
tbl.ColAndIdxExistenceMap.InsertCol(item.ID, colHist.StatsAvailable())
} else if item.IsIndex && idxHist != nil {
index := tbl.GetIdx(item.ID)
Expand Down
5 changes: 5 additions & 0 deletions pkg/statistics/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import (
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/planner/planctx"
statslogutil "github.com/pingcap/tidb/pkg/statistics/handle/logutil"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/ranger"
"go.uber.org/atomic"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -1096,6 +1098,9 @@ func PseudoTable(tblInfo *model.TableInfo, allowTriggerLoading bool, allowFillHi
// We would not collect stats for the hidden column and we won't use the hidden column to estimate.
// Thus we don't create pseudo stats for it.
if col.State == model.StatePublic && !col.Hidden {
statslogutil.StatsLogger().Info("stat cache map insert col 1",
zap.Int64("tableID", tblInfo.ID),
zap.Int64("colID", col.ID))
t.ColAndIdxExistenceMap.InsertCol(col.ID, false)
if allowFillHistMeta {
t.columns[col.ID] = &Column{
Expand Down