Skip to content

Commit 52b888e

Browse files
committed
add log
Signed-off-by: Ruihao Chen <[email protected]>
1 parent 76b6293 commit 52b888e

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

pkg/statistics/handle/bootstrap.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ func (*Handle) initStatsHistograms4ChunkLite(cache statstypes.StatsCache, iter *
162162
table.LastAnalyzeVersion = max(table.LastAnalyzeVersion, row.GetUint64(4))
163163
}
164164
} else {
165+
statslogutil.StatsLogger().Info("stat cache map insert col 2",
166+
zap.Int64("tableID", table.PhysicalID),
167+
zap.Int64("colID", id))
165168
table.ColAndIdxExistenceMap.InsertCol(id, statsVer != statistics.Version0 || ndv > 0 || nullCount > 0)
166169
if statsVer != statistics.Version0 {
167170
// The LastAnalyzeVersion is added by ALTER table so its value might be 0.
@@ -267,6 +270,9 @@ func (h *Handle) initStatsHistograms4Chunk(is infoschema.InfoSchema, cache stats
267270
StatsVer: statsVer,
268271
}
269272
table.SetCol(hist.ID, col)
273+
statslogutil.StatsLogger().Info("stat cache map insert col 3",
274+
zap.Int64("tableID", table.PhysicalID),
275+
zap.Int64("colID", colInfo.ID))
270276
table.ColAndIdxExistenceMap.InsertCol(colInfo.ID, statsVer != statistics.Version0 || ndv > 0 || nullCount > 0)
271277
if statsVer != statistics.Version0 {
272278
// The LastAnalyzeVersion is added by ALTER table so its value might be 0.

pkg/statistics/handle/cache/statscache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ func (s *StatsCacheImpl) Get(tableID int64) (*statistics.Table, bool) {
328328

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

pkg/statistics/handle/storage/read.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ func columnStatsFromStorage(sctx sessionctx.Context, row chunk.Row, table *stati
400400
if histID != colInfo.ID {
401401
continue
402402
}
403+
statslogutil.StatsLogger().Info("stat cache map insert col 4",
404+
zap.Int64("tableID", table.PhysicalID),
405+
zap.Int64("colID", histID))
403406
table.ColAndIdxExistenceMap.InsertCol(histID, statsVer != statistics.Version0 || distinct > 0 || nullCount > 0)
404407
// All the objects in the table shares the same stats version.
405408
// Update here.

pkg/statistics/handle/syncload/stats_syncload.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,13 +594,19 @@ func (s *statsSyncLoad) updateCachedItem(item model.TableItemID, colHist *statis
594594

595595
// If the column is analyzed we refresh the map for the possible change.
596596
if colHist.StatsAvailable() {
597+
statslogutil.StatsLogger().Info("stat cache map insert col 5",
598+
zap.Int64("tableID", tbl.PhysicalID),
599+
zap.Int64("colID", item.ID))
597600
tbl.ColAndIdxExistenceMap.InsertCol(item.ID, true)
598601
}
599602
// All the objects shares the same stats version. Update it here.
600603
if colHist.StatsVer != statistics.Version0 {
601604
tbl.StatsVer = statistics.Version0
602605
}
603606
// we have to refresh the map for the possible change to ensure that the map information is not missing.
607+
statslogutil.StatsLogger().Info("stat cache map insert col 6",
608+
zap.Int64("tableID", tbl.PhysicalID),
609+
zap.Int64("colID", item.ID))
604610
tbl.ColAndIdxExistenceMap.InsertCol(item.ID, colHist.StatsAvailable())
605611
} else if item.IsIndex && idxHist != nil {
606612
index := tbl.GetIdx(item.ID)

pkg/statistics/table.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import (
2525
"github.com/pingcap/tidb/pkg/meta/model"
2626
"github.com/pingcap/tidb/pkg/parser/mysql"
2727
"github.com/pingcap/tidb/pkg/planner/planctx"
28+
statslogutil "github.com/pingcap/tidb/pkg/statistics/handle/logutil"
2829
"github.com/pingcap/tidb/pkg/types"
2930
"github.com/pingcap/tidb/pkg/util/ranger"
3031
"go.uber.org/atomic"
32+
"go.uber.org/zap"
3133
)
3234

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

0 commit comments

Comments
 (0)