Skip to content

Commit

Permalink
always push isnull to block filters (matrixorigin#16851)
Browse files Browse the repository at this point in the history
always push isnull to block filters

Approved by: @aunjgr
  • Loading branch information
badboynt1 authored Jun 14, 2024
1 parent 7ced499 commit 16a2113
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/sql/plan/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func estimateFilterBlockSelectivity(ctx context.Context, expr *plan.Expr, tableD
}
col := extractColRefInFilter(expr)
if col != nil {
blocksel := calcBlockSelectivityUsingShuffleRange(s.ShuffleRangeMap[col.Name], expr.Selectivity)
blocksel := calcBlockSelectivityUsingShuffleRange(s.ShuffleRangeMap[col.Name], expr)
switch GetSortOrder(tableDef, col.ColPos) {
case 0:
blocksel = math.Min(blocksel, 0.2)
Expand Down Expand Up @@ -1341,8 +1341,13 @@ func DeepCopyStats(stats *plan.Stats) *plan.Stats {
}
}

func calcBlockSelectivityUsingShuffleRange(s *pb.ShuffleRange, sel float64) float64 {
func calcBlockSelectivityUsingShuffleRange(s *pb.ShuffleRange, expr *plan.Expr) float64 {
sel := expr.Selectivity
if s == nil {
if expr.GetF().Func.ObjName == "isnull" || expr.GetF().Func.ObjName == "is_null" {
//speicial handle for isnull
return sel
}
if sel <= 0.01 {
return sel * 100
} else {
Expand Down

0 comments on commit 16a2113

Please sign in to comment.