Skip to content

Commit

Permalink
cp to 1.2-dev 'fix ndv calculation to make it more accurate' (#18848)
Browse files Browse the repository at this point in the history
fix ndv calculation to make it more accurate

Approved by: @triump2020, @XuPeng-SH, @sukki37
  • Loading branch information
badboynt1 authored Sep 19, 2024
1 parent 75ae7b4 commit 5cd387f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/vm/engine/disttae/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,12 @@ func adjustNDV(info *plan2.InfoFromZoneMap, tableDef *plan2.TableDef) {
}
if rate < 0.1 {
info.ColumnNDVs[idx] /= math.Pow(float64(info.AccurateObjectNumber), (1 - rate))
if info.ColumnNDVs[idx] > 500 {
info.ColumnNDVs[idx] *= math.Pow(info.ColumnNDVs[idx], 0.2)
if info.ColumnSize[idx] > 0 {
info.ColumnNDVs[idx] *= math.Pow(float64(info.ColumnSize[idx]), 0.2)
}
}
}
ndvUsingZonemap := calcNdvUsingZonemap(info.ColumnZMs[idx], &info.DataTypes[idx])
if ndvUsingZonemap != -1 && info.ColumnNDVs[idx] > ndvUsingZonemap {
Expand Down

0 comments on commit 5cd387f

Please sign in to comment.