[
https://issues.apache.org/jira/browse/CALCITE-6788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17913611#comment-17913611
]
Ruben Q L edited comment on CALCITE-6788 at 1/16/25 8:46 AM:
-------------------------------------------------------------
I understand [~cbrisson]'s logic. Currently when a rule finalizes its job and
generates a "new plan", the planner evaluates the plan candidates costs using
its own getCost method (which can be overridden, such as in
HiveVolcanoPlanner). However, in the intermediate steps of
LoptOptimizeJoinRule, intermediate plans (which can be potential result plans)
are evaluated (hence considered or discarded) based on the mq#getCumulativeCost
instead of the planner#getCost. This looks like a mismatch and may cause
potential better plan results to be "lost" in these intermediate computations
of LoptOptimizeJoinRule.
was (Author: rubenql):
I undesrtand [~cbrisson]'s logic. Currently when a rule finalizes its job and
generates a "new plan", the planner evaluates the plan candidates costs using
its own getCost method (which can be overridden, such as in
HiveVolcanoPlanner). However, in the intermediate steps of
LoptOptimizeJoinRule, intermediate plans (which can be potential result plans)
are evaluated (hence considered or discarded) based on the mq#getCumulativeCost
instead of the planner#getCost. This looks like a mismatch and may cause
potential better plan results to be "lost" in these intermediate computations
of LoptOptimizeJoinRule.
> LoptOptimizeJoinRule should delegate costs to optimization planner
> ------------------------------------------------------------------
>
> Key: CALCITE-6788
> URL: https://issues.apache.org/jira/browse/CALCITE-6788
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.38.0
> Reporter: Claude Brisson
> Priority: Major
> Labels: pull-request-available
>
> {{LoptOptimizeJoinRule}} uses costs comparisons to recursively decide whether
> to add a join at the top of the joins tree or to push it down.
> When doing so, instead of directly calling {{mq.getCumulativeCost(rel)}}, it
> should rely on {{call.getPlanner.getCost(rel, mq)}}, which will be used
> thereafter to choose the best joins tree.
> This way, it becomes possible to customize the costs computation during the
> heuristic joins ordering phase by just overriding the {{getCost()}} method of
> the optimization planner.
> Without this patch, it is only possible to alter joins costs at the final
> phase of the algorithm, which defeats the goal of customizing them, including
> during the to-top/push-down phase.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)