xndai commented on a change in pull request #1440: [CALCITE-2166] Cumulative 
cost of RelSubset.best RelNode is increased…
URL: https://github.com/apache/calcite/pull/1440#discussion_r321991108
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
 ##########
 @@ -344,15 +344,29 @@ void propagateCostImprovements0(VolcanoPlanner planner, 
RelMetadataQuery mq,
       return;
     }
     try {
-      final RelOptCost cost = planner.getCost(rel, mq);
-      if (cost.isLt(bestCost)) {
-        LOGGER.trace("Subset cost improved: subset [{}] cost was {} now {}", 
this, bestCost, cost);
+      RelOptCost cost = planner.getCost(rel, mq);
+      boolean updateBest = cost.isLt(bestCost);
+
+      // Best rel's cost is increased, we need to search for new best rel
+      if (rel == best && bestCost.isLt(cost)) {
+        updateBest = true;
 
 Review comment:
   We only need to update best when its own cost is increased. If this is any 
other rel node and its cost is larger than current best, we simply ignore (same 
behavior as today). I think I have explained the case when this could happen. 
Please check the descriptions and JIRA. Let me know if you have further 
question. Thanks.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to