This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 518b143caa4c1a94cc89156558886400b8c00a27 Author: minghong <engle...@gmail.com> AuthorDate: Mon May 20 10:06:51 2024 +0800 [feat](Nereids)choose agg mv in cbo #35020 --- .../java/org/apache/doris/nereids/cost/CostModelV1.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java index d469dd3b40b..87e0f8ab9fa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java @@ -17,6 +17,8 @@ package org.apache.doris.nereids.cost; +import org.apache.doris.catalog.KeysType; +import org.apache.doris.catalog.OlapTable; import org.apache.doris.nereids.PlanContext; import org.apache.doris.nereids.properties.DistributionSpec; import org.apache.doris.nereids.properties.DistributionSpecGather; @@ -97,8 +99,17 @@ class CostModelV1 extends PlanVisitor<Cost, PlanContext> { @Override public Cost visitPhysicalOlapScan(PhysicalOlapScan physicalOlapScan, PlanContext context) { + OlapTable table = physicalOlapScan.getTable(); Statistics statistics = context.getStatisticsWithCheck(); - return CostV1.ofCpu(context.getSessionVariable(), statistics.getRowCount()); + double rows = statistics.getRowCount(); + double aggMvBonus = 0.0; + if (table.getBaseIndexId() != physicalOlapScan.getSelectedIndexId()) { + if (table.getIndexMetaByIndexId(physicalOlapScan.getSelectedIndexId()) + .getKeysType().equals(KeysType.AGG_KEYS)) { + aggMvBonus = rows > 1.0 ? 1.0 : rows * 0.5; + } + } + return CostV1.ofCpu(context.getSessionVariable(), rows - aggMvBonus); } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org