TJ Banghart created CALCITE-7254:
------------------------------------

             Summary: Add a rule for sharing trivially equivelent RelNodes 
within Combine
                 Key: CALCITE-7254
                 URL: https://issues.apache.org/jira/browse/CALCITE-7254
             Project: Calcite
          Issue Type: New Feature
    Affects Versions: 1.40.0
            Reporter: TJ Banghart
            Assignee: TJ Banghart


Introduce an optimization rule to identify and consolidate trivially equivalent 
{{RelNodes}} that appear within a {{Combine}} operator. Trivial equivalence is 
defined as two {{RelNodes}} having identical digests. When such equivalence is 
detected, the common subexpression should be lifted into a shared {{Spool}} 
reference, and each original occurrence should be replaced with a dependent on 
that {{{}Spool{}}}.

An implementation may be able to build on the existing 
{{{}RelCommonExpressionSuggester{}}}, which currently identifies common 
expressions within individual queries. It may need to be extended to consider 
multiple queries or multiple branches within a single {{{}Combine{}}}.

An important consideration will be how {{Combine}} handles cost estimation in 
the absence of optimization and how shared expressions might influence that 
model. We will likely need to evaluate how these lifted expressions interact 
with the cost model to ensure we aren’t over-rewarding shared subtrees or 
unintentionally skewing plan selection.

We'd have to take care when managing interactions with other optimization 
rules. Filter pushdown, projection trimming, join reordering, etc... can alter 
digests and preclude trivial equivalence. The new rule will need safeguards to 
prevent conflicts or premature firing relative to these other optimizations.

Some of the implementation details are likely to evolve as this develops. 
Initial focus would be on correctness and identifying the right insertion 
points in the optimization pipeline.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to