Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4501

Clear costs in VolcanoPlanner when setting the new root

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 1.26.0
    • None
    • core
    • 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:

      1. The cluster object has a reference to MetadataQuery with possibly cached costs. This may lead to a mix of different cost models.
      2. VolcanoPlanner caches zero and infinite costs in a final variable.

      In this issue, I propose to introduce two slight modifications to the VolcanoPlanner:

      1. Clear the metadata query from within setRoot method.
      2. 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

          Activity

            People

              vozerov Vladimir Ozerov
              vozerov Vladimir Ozerov
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m