Skip to content

Commit

Permalink
cp to 1.2-dev 'fix the condition for runtime filters (#18496)' (#18860)
Browse files Browse the repository at this point in the history
cp to 1.2-dev 'fix the condition for runtime filters (#18496)'

Approved by: @ouyuanning, @aunjgr, @sukki37
  • Loading branch information
badboynt1 authored Sep 20, 2024
1 parent 3f5bca9 commit f2dd397
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/sql/plan/agg_pushdown_pullup.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func applyAggPushdown(agg, join, leftChild *plan.Node, builder *QueryBuilder) {
replaceCol(agg.AggList[0], leftChildTag, colAgg.Col.ColPos, newAggTag, 0)
}

// agg pushdown only support node->(filter)->inner join->agg for now
// we can change it to node->agg->(filter)->inner join
func (builder *QueryBuilder) aggPushDown(nodeID int32) int32 {
if builder.optimizerHints != nil && builder.optimizerHints.aggPushDown != 0 {
return nodeID
Expand Down Expand Up @@ -338,8 +340,8 @@ func applyAggPullup(rootID int32, join, agg, leftScan, rightScan *plan.Node, bui
}

func (builder *QueryBuilder) aggPullup(rootID, nodeID int32) int32 {
// agg pullup only support node->(filter)->inner join->agg for now
// we can change it to node->agg->(filter)->inner join
// agg pullup only support node->agg->(filter)->inner join for now
// we can change it to node->(filter)->inner join->agg
if builder.optimizerHints != nil && builder.optimizerHints.aggPullUp != 0 {
return nodeID
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/plan/runtime_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (builder *QueryBuilder) generateRuntimeFilters(nodeID int32) {
}

rightChild := builder.qry.Nodes[node.Children[1]]
if node.JoinType != plan.Node_INDEX && rightChild.Stats.Selectivity > 0.5 {
if node.JoinType != plan.Node_INDEX && rightChild.Stats.Outcnt > 5000000 {
return
}

Expand Down

0 comments on commit f2dd397

Please sign in to comment.