Skip to content

Commit

Permalink
adjust agg cost
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Aug 9, 2024
1 parent 547ff3c commit 0520b2f
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,16 @@ public Cost visitPhysicalHashAggregate(
PhysicalHashAggregate<? extends Plan> aggregate, PlanContext context) {
Statistics inputStatistics = context.getChildStatistics(0);
double exprCost = expressionTreeCost(aggregate.getExpressions());
double aggCostBaseFactor = 3;
if (aggregate.getAggPhase().isLocal()) {
return CostV1.of(context.getSessionVariable(),
exprCost / 100 + inputStatistics.getRowCount() / beNumber,
inputStatistics.getRowCount() / beNumber, 0);
exprCost / 100 + aggCostBaseFactor * inputStatistics.getRowCount() / beNumber,
aggCostBaseFactor * inputStatistics.getRowCount() / beNumber, 0);
} else {
// global
return CostV1.of(context.getSessionVariable(), exprCost / 100 + inputStatistics.getRowCount(),
inputStatistics.getRowCount(), 0);
return CostV1.of(context.getSessionVariable(), exprCost / 100
+ aggCostBaseFactor * inputStatistics.getRowCount(),
aggCostBaseFactor * inputStatistics.getRowCount(), 0);
}
}

Expand Down

0 comments on commit 0520b2f

Please sign in to comment.