Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Won't Fix
-
1.26.0
-
None
-
None
Description
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.
Attachments
Issue Links
- is related to
-
CALCITE-4111 Remove VolcanoPlannerPhase in VolcanoPlanner
- Closed
- links to