Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Nov 12, 2024
1 parent 492e41d commit d589bd6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/planner/core/rule_collect_plan_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ func (*CollectPredicateColumnsPoint) markAtLeastOneFullStatsLoadForEachTable(
histNeeded bool,
) {
statsHandle := domain.GetDomain(sctx).StatsHandle()
if statsHandle == nil {
// If there's no stats handler, it's abnormal status. Return directly.
return
}
physTblIDsWithNeededCols := intset.NewFastIntSet()
for neededCol, fullLoad := range predicateCols {
if !fullLoad {
continue
}
if statsHandle == nil {
continue
}
tblInfo := tblID2TblInfo[neededCol.TableID]
// If we don't find its table info, it might be deleted. Skip.
if tblInfo == nil {
continue
}
Expand All @@ -126,11 +128,9 @@ func (*CollectPredicateColumnsPoint) markAtLeastOneFullStatsLoadForEachTable(
}

// 2. get the stats table

// If we already collected some columns that need trigger sync laoding on this table, we don't need to
// If we already collected some columns that need trigger sync loading on this table, we don't need to
// additionally do anything for determinate mode.
if physTblIDsWithNeededCols.Has(physicalTblID) ||
statsHandle == nil {
if physTblIDsWithNeededCols.Has(physicalTblID) {
return
}
tblStats := statsHandle.GetTableStats(tbl)
Expand All @@ -152,6 +152,7 @@ func (*CollectPredicateColumnsPoint) markAtLeastOneFullStatsLoadForEachTable(
// Choose the first column we meet to trigger stats loading.
if colToTriggerLoad == nil {
colToTriggerLoad = &model.TableItemID{TableID: int64(physicalTblID), ID: col.ID, IsIndex: false}
break
}
}
if colToTriggerLoad == nil {
Expand Down

0 comments on commit d589bd6

Please sign in to comment.