This is an automated email from the ASF dual-hosted git repository. jakevin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 61d4974ba1 [fix](Nereids) Use simple cost to calculate benefit and avoid unuseless calculation (#14056) 61d4974ba1 is described below commit 61d4974ba1d5c1affd7e69a31cfc98e693711f32 Author: 谢健 <jianx...@gmail.com> AuthorDate: Tue Nov 8 13:11:38 2022 +0800 [fix](Nereids) Use simple cost to calculate benefit and avoid unuseless calculation (#14056) In GraphSimplifier, we can use simple cost to calculate the benefit. And only when the best neighbor of the apply step is the processing edge, we need to update recursively. --- .../joinreorder/hypergraph/GraphSimplifier.java | 11 +++++------ .../nereids/rules/joinreorder/hypergraph/Node.java | 1 - .../joinreorder/hypergraph/GraphSimplifierTest.java | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifier.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifier.java index 693b0f2044..1bfb0e1a38 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifier.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifier.java @@ -128,7 +128,9 @@ public class GraphSimplifier { edgeIndex1)) { continue; } - processNeighbors(edgeIndex2, 0, edgeSize); + if (bestSimplification.bestNeighbor == edgeIndex1) { + processNeighbors(edgeIndex2, 0, edgeSize); + } } // Go through the neighbors with higher index, we only need to recalculate all related steps @@ -289,17 +291,14 @@ public class GraphSimplifier { private LogicalJoin simulateJoin(Plan plan1, LogicalJoin join, Plan plan2) { // In Graph Simplifier, we use the simple cost model, that is - // Plan.cost = Plan.rowCount + Plan.children1.cost + ... + // Plan.cost = Plan.rowCount + Plan.children1.cost + Plan.children2.cost // The reason is that this cost model has ASI (adjacent sequence interchange) property. // TODO: consider network, data distribution cost - double cost = 0; LogicalJoin newJoin = new LogicalJoin(join.getJoinType(), plan1, plan2); List<Group> children = new ArrayList<>(); - cost += getGroup(plan1).getStatistics().getRowCount(); children.add(getGroup(plan1)); - cost += getGroup(plan2).getStatistics().getRowCount(); children.add(getGroup(plan2)); - + double cost = getSimpleCost(plan1) + getSimpleCost(plan2); GroupExpression groupExpression = new GroupExpression(newJoin, children); Group group = new Group(); group.addGroupExpression(groupExpression); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/Node.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/Node.java index 8fa93d223f..a2d7696c85 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/Node.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/Node.java @@ -97,7 +97,6 @@ class Node { } else { complexEdges.remove(edge); } - assert false : String.format("removed edge %d at %d that does not exists", edge.getIndex(), index); } public String getName() { diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifierTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifierTest.java index d0c71ebfd2..6f599ef763 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifierTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/joinreorder/hypergraph/GraphSimplifierTest.java @@ -48,22 +48,22 @@ public class GraphSimplifierTest { + " rowCount=40.00\"];\n" + " LOGICAL_OLAP_SCAN4 [label=\"LOGICAL_OLAP_SCAN4 \n" + " rowCount=50.00\"];\n" - + "e0 [shape=circle, width=.001, label=\"\"]\n" - + "LOGICAL_OLAP_SCAN0 -> e0 [arrowhead=none, label=\"0.10\"]\n" - + "LOGICAL_OLAP_SCAN2 -> e0 [arrowhead=none, label=\"0.10\"]\n" - + "LOGICAL_OLAP_SCAN3 -> e0 [arrowhead=none, label=\"0.10\"]\n" - + "LOGICAL_OLAP_SCAN4 -> e0 [arrowhead=none, label=\"0.10\"]\n" - + "LOGICAL_OLAP_SCAN1 -> e0 [arrowhead=none, label=\"\"]\n" + + "LOGICAL_OLAP_SCAN0 -> LOGICAL_OLAP_SCAN1 [label=\"0.10\",arrowhead=none]\n" + "e1 [shape=circle, width=.001, label=\"\"]\n" + "LOGICAL_OLAP_SCAN0 -> e1 [arrowhead=none, label=\"0.05\"]\n" - + "LOGICAL_OLAP_SCAN3 -> e1 [arrowhead=none, label=\"0.05\"]\n" - + "LOGICAL_OLAP_SCAN4 -> e1 [arrowhead=none, label=\"0.05\"]\n" + + "LOGICAL_OLAP_SCAN1 -> e1 [arrowhead=none, label=\"0.05\"]\n" + "LOGICAL_OLAP_SCAN2 -> e1 [arrowhead=none, label=\"\"]\n" + "e2 [shape=circle, width=.001, label=\"\"]\n" + "LOGICAL_OLAP_SCAN0 -> e2 [arrowhead=none, label=\"0.03\"]\n" - + "LOGICAL_OLAP_SCAN4 -> e2 [arrowhead=none, label=\"0.03\"]\n" + + "LOGICAL_OLAP_SCAN1 -> e2 [arrowhead=none, label=\"0.03\"]\n" + + "LOGICAL_OLAP_SCAN2 -> e2 [arrowhead=none, label=\"0.03\"]\n" + "LOGICAL_OLAP_SCAN3 -> e2 [arrowhead=none, label=\"\"]\n" - + "LOGICAL_OLAP_SCAN0 -> LOGICAL_OLAP_SCAN4 [label=\"0.03\",arrowhead=none]\n" + + "e3 [shape=circle, width=.001, label=\"\"]\n" + + "LOGICAL_OLAP_SCAN0 -> e3 [arrowhead=none, label=\"0.03\"]\n" + + "LOGICAL_OLAP_SCAN1 -> e3 [arrowhead=none, label=\"0.03\"]\n" + + "LOGICAL_OLAP_SCAN2 -> e3 [arrowhead=none, label=\"0.03\"]\n" + + "LOGICAL_OLAP_SCAN3 -> e3 [arrowhead=none, label=\"0.03\"]\n" + + "LOGICAL_OLAP_SCAN4 -> e3 [arrowhead=none, label=\"\"]\n" + "}\n"; String dottyGraph = hyperGraph.toDottyHyperGraph(); assert dottyGraph.equals(target) : dottyGraph; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org