Hi, I've found there are two ways to compute the cumulative cost, and they happen to be quite different.
VolcanoPlanner#getCost seems to be the right one (see [1]) It properly accounts for RelSubset and uses its bestCost On the other hand, mq.getCumulativeCost(rel) is quite poor (see [2]). It knows nothing on RelSubsets, so it produces wrong numbers. Unfortunately, explain with all attributes is using bad API [2] (see [3]). Any thoughts on unifying the APIs? I can imagine two approaches: A) Implement RelSubset#computeSelfCost as "return bestCost". That would probably make VolcanoPlanner's getCost obsolete. B) Remove mq.getCumulativeCost and divert all the uses to planner#getCost [1]: https://github.com/apache/calcite/blob/763ec429c951acd5fa251c5d4a2b7780fbf648d4/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java#L955-L973 [2]: https://github.com/apache/calcite/blob/763ec429c951acd5fa251c5d4a2b7780fbf648d4/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPercentageOriginalRows.java#L158-L170 [3]: https://github.com/apache/calcite/blob/763ec429c951acd5fa251c5d4a2b7780fbf648d4/core/src/main/java/org/apache/calcite/rel/externalize/RelWriterImpl.java#L98-L102 Vladimir