Skip to content

Commit 8a56eab

Browse files
authored
planner: quickly get total count from index/column (#58365) (#58431)
close #58366
1 parent 8c97a5a commit 8a56eab

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/planner/cardinality/ndv.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,18 @@ func getTotalRowCount(statsTbl *statistics.Table, colHist *statistics.Column) in
5151
}
5252
// If colHist is not fully loaded, we may still get its total row count from other index/column stats.
5353
totCount := int64(0)
54+
stop := false
5455
statsTbl.ForEachIndexImmutable(func(_ int64, idx *statistics.Index) bool {
5556
if idx.IsFullLoad() && idx.LastUpdateVersion == colHist.LastUpdateVersion {
5657
totCount = int64(idx.TotalRowCount())
58+
stop = true
5759
return true
5860
}
5961
return false
6062
})
63+
if stop {
64+
return totCount
65+
}
6166
statsTbl.ForEachColumnImmutable(func(_ int64, col *statistics.Column) bool {
6267
if col.IsFullLoad() && col.LastUpdateVersion == colHist.LastUpdateVersion {
6368
totCount = int64(col.TotalRowCount())

0 commit comments

Comments
 (0)