From f2dd397821681b7484b9250e86c66bc21515b28b Mon Sep 17 00:00:00 2001 From: nitao Date: Fri, 20 Sep 2024 11:10:42 +0800 Subject: [PATCH] cp to 1.2-dev 'fix the condition for runtime filters (#18496)' (#18860) cp to 1.2-dev 'fix the condition for runtime filters (#18496)' Approved by: @ouyuanning, @aunjgr, @sukki37 --- pkg/sql/plan/agg_pushdown_pullup.go | 6 ++++-- pkg/sql/plan/runtime_filter.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/sql/plan/agg_pushdown_pullup.go b/pkg/sql/plan/agg_pushdown_pullup.go index 562f1c02344bf..4b0108633cd04 100644 --- a/pkg/sql/plan/agg_pushdown_pullup.go +++ b/pkg/sql/plan/agg_pushdown_pullup.go @@ -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 @@ -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 } diff --git a/pkg/sql/plan/runtime_filter.go b/pkg/sql/plan/runtime_filter.go index e62e6a8d7cdc0..7b7c7c0665f0f 100644 --- a/pkg/sql/plan/runtime_filter.go +++ b/pkg/sql/plan/runtime_filter.go @@ -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 }