[
https://issues.apache.org/jira/browse/CALCITE-4501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17285820#comment-17285820
]
Vladimir Ozerov commented on CALCITE-4501:
------------------------------------------
[~julianhyde] thank you for your comments. I agree that cost clearing could be
beneficial for some cases, but bad for others. I've closed the PR for now,
because it is possible to clear cached costs manually.
However, the problem with the final {{infCost}} and {{zeroCost}} fields in the
{{VolcanoPlanner}} remains. Do you think it is ok to make them non-final and
add the ability to re-initialize them?
> Clear costs in VolcanoPlanner when setting the new root
> -------------------------------------------------------
>
> Key: CALCITE-4501
> URL: https://issues.apache.org/jira/browse/CALCITE-4501
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.26.0
> Reporter: Vladimir Ozerov
> Assignee: Vladimir Ozerov
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> In production-grade systems, the optimization is typically performed in
> several phases. The same instance of {{VolcanoPlanner}} tends to be re-used
> between the phases.
> In some sophisticated scenarios, we may want to alter the cost function
> between phases.
> For example, to adjust the weights of some operators depending on some
> heuristics, or even switch to a completely different cost model.
> One way to do that is to re-instantiate the cluster and the planner with the
> new cost function.
> However, it requires copying of the current rel tree, because its nodes still
> point to the old cluster. This may negatively affect the performance.
> The alternative approach could be to change the state of the cost factory.
> However, it would not work for two reasons:
> # The cluster object has a reference to {{MetadataQuery}} with possibly
> cached costs. This may lead to a mix of different cost models.
> # {{VolcanoPlanner}} caches zero and infinite costs in a final variable.
> In this issue, I propose to introduce two slight modifications to the
> {{VolcanoPlanner}}:
> # Clear the metadata query from within {{setRoot}} method.
> # Make {{infCost}} and {{zeroCost}} non-final, and also re-initialize them in
> the {{setRoot}} method.
> The {{setRoot}} method is convenient for these purposes because it is invoked
> from the {{RuleSetProgram}}, so the desired cost cleanup will work with no
> modifications to the application's code.
> Please let me know if you think that this change is not valid.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)