NobiGo commented on code in PR #3851:
URL: https://github.com/apache/calcite/pull/3851#discussion_r1676837040


##########
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java:
##########
@@ -982,11 +982,17 @@ void propagateCostImprovements(RelNode rel) {
         if (!relNode.getTraitSet().satisfies(subset.getTraitSet())) {
           continue;
         }
-        if (!cost.isLt(subset.bestCost)) {
+
+        // Update subset best and best's cost when we find a cheaper rel
+        if (relNode != subset.best && !cost.isLt(subset.bestCost)) {
           continue;
         }
-        // Update subset best cost when we find a cheaper rel or the current
-        // best's cost is changed
+
+        // Update the current best's cost when we find cost is changed
+        if (relNode == subset.best && cost.equals(subset.bestCost)) {

Review Comment:
   Hi  @YiwenWu , This is because RelSet's one of the subset find a cheaper 
rel's cost,  We need to update the  parents the best rel and best cost. In 
theory, this cost will become smaller, But according to the debug info, The SQL 
I added in the JdbcAdapterTest shows same rel node 's cost sometimes will 
become bigger. So I update it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to