Skip to content

Commit ee00459

Browse files
authored
statistics: BCE for the async global stats (pingcap#49997)
close pingcap#50030
1 parent 49dfd93 commit ee00459

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/statistics/handle/globalstats/global_stats_async.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,18 @@ func (a *AsyncMergePartitionStats2GlobalStats) dealHistogramAndTopN(stmtCtx *stm
515515
}
516516

517517
// Merge histogram.
518-
a.globalStats.Hg[item.idx], err = statistics.MergePartitionHist2GlobalHist(stmtCtx, allhg, poppedTopN,
518+
globalHg := &(a.globalStats.Hg[item.idx])
519+
*globalHg, err = statistics.MergePartitionHist2GlobalHist(stmtCtx, allhg, poppedTopN,
519520
int64(opts[ast.AnalyzeOptNumBuckets]), isIndex)
520521
if err != nil {
521522
return err
522523
}
523524

524525
// NOTICE: after merging bucket NDVs have the trend to be underestimated, so for safe we don't use them.
525-
for j := range a.globalStats.Hg[item.idx].Buckets {
526-
a.globalStats.Hg[item.idx].Buckets[j].NDV = 0
526+
for j := range (*globalHg).Buckets {
527+
(*globalHg).Buckets[j].NDV = 0
527528
}
528-
a.globalStats.Hg[item.idx].NDV = a.globalStatsNDV[item.idx]
529+
(*globalHg).NDV = a.globalStatsNDV[item.idx]
529530
case <-a.ioWorkerExitWhenErrChan:
530531
return nil
531532
}

0 commit comments

Comments
 (0)