Skip to content

Commit

Permalink
planner: quickly get total count from index/column (#58365)
Browse files Browse the repository at this point in the history
close #58366
  • Loading branch information
hawkingrei authored Dec 19, 2024
1 parent 85f3f9c commit 1fa2955
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/planner/cardinality/ndv.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ func getTotalRowCount(statsTbl *statistics.Table, colHist *statistics.Column) in
}
// If colHist is not fully loaded, we may still get its total row count from other index/column stats.
totCount := int64(0)
stop := false
statsTbl.ForEachIndexImmutable(func(_ int64, idx *statistics.Index) bool {
if idx.IsFullLoad() && idx.LastUpdateVersion == colHist.LastUpdateVersion {
totCount = int64(idx.TotalRowCount())
stop = true
return true
}
return false
})
if stop {
return totCount
}
statsTbl.ForEachColumnImmutable(func(_ int64, col *statistics.Column) bool {
if col.IsFullLoad() && col.LastUpdateVersion == colHist.LastUpdateVersion {
totCount = int64(col.TotalRowCount())
Expand Down

0 comments on commit 1fa2955

Please sign in to comment.