[opt](Nereids) forbid some bad pattern aggregate in AggregateStrategy (#18877)
since we cannot do stats derive and cost estimate on agg very good. this PR remove some aggregate pattern that usually not good. 1. one stage agg after exchange. this pattern is good only when process very few rows. 2. three stage distinct agg with gather middle merge.
This commit is contained in:
@ -24,6 +24,7 @@ import org.apache.doris.nereids.jobs.JobContext;
|
||||
import org.apache.doris.nereids.memo.GroupExpression;
|
||||
import org.apache.doris.nereids.properties.DistributionSpecHash.ShuffleType;
|
||||
import org.apache.doris.nereids.trees.expressions.ExprId;
|
||||
import org.apache.doris.nereids.trees.plans.AggMode;
|
||||
import org.apache.doris.nereids.trees.plans.Plan;
|
||||
import org.apache.doris.nereids.trees.plans.physical.PhysicalDistribute;
|
||||
import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate;
|
||||
@ -77,6 +78,10 @@ public class ChildrenPropertiesRegulator extends PlanVisitor<Double, Void> {
|
||||
|
||||
@Override
|
||||
public Double visitPhysicalHashAggregate(PhysicalHashAggregate<? extends Plan> agg, Void context) {
|
||||
if (agg.getAggMode() == AggMode.INPUT_TO_RESULT
|
||||
&& children.get(0).getPlan() instanceof PhysicalDistribute) {
|
||||
return -1.0;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
@ -980,7 +980,8 @@ public class AggregateStrategies implements ImplementationRuleFactory {
|
||||
|
||||
if (logicalAgg.getGroupByExpressions().isEmpty()) {
|
||||
return ImmutableList.<PhysicalHashAggregate<? extends Plan>>builder()
|
||||
.add(anyLocalGatherGlobalGatherDistinctAgg)
|
||||
// TODO: this plan pattern is not good usually, we remove it temporary.
|
||||
// .add(anyLocalGatherGlobalGatherDistinctAgg)
|
||||
.add(anyLocalHashGlobalGatherDistinctAgg)
|
||||
.build();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user