Add length check to prevent index out of range (#4864)
This commit is contained in:
@ -74,7 +74,7 @@ func (p *DataSource) getStatsProfileByFilter(conds expression.CNFExprs) *statsPr
|
||||
}
|
||||
for i, col := range p.Columns {
|
||||
hist, ok := p.statisticTable.Columns[col.ID]
|
||||
if ok && hist.NDV > 0 {
|
||||
if ok && hist.NDV > 0 && len(hist.Buckets) > 0 {
|
||||
factor := float64(p.statisticTable.Count) / float64(hist.Buckets[len(hist.Buckets)-1].Count)
|
||||
profile.cardinality[i] = float64(hist.NDV) * factor
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user