Remus Rusanu created CALCITE-1812:
-------------------------------------

             Summary: Provide RelMetadataQuery from planner to rules and 
invalidate in transformTo
                 Key: CALCITE-1812
                 URL: https://issues.apache.org/jira/browse/CALCITE-1812
             Project: Calcite
          Issue Type: Improvement
          Components: core
            Reporter: Remus Rusanu
            Assignee: Remus Rusanu


Currently rules create a needed {{RelMetadataQuery}} when matched (ie. 
{{RuleXxx.onMatch}}. Since rules are called often, on complex query this 
triggers a multiplication RMQ instances used. But each new instance carries a 
heavy price on performance, because is the RMQ instance that hosts the cache 
used to memoize various metadata lookups (like getEstimatedRows, 
getPulledUpPredicates, uniqueness and so on). From HIVE-16757 investigation, 
the performance impact can be 10x.

The proposal is to have a RelMetadataQuery in the planner and pass it to the 
rules as a RelOptRuleCall property. Rules {{onMatch}} can make use of this 
instance. The rule call {{transformTo}} can handle invalidating the RMQ 
instance.

If code knowingly invalidates metadata properties associated with a node by 
means other than transformTo, it should somehow invalidate the current RMQ.

The RMQ invalidation can be made smarter, but my plan right now is to do the 
dumb thing and just toss it away. Will revisit this later, depending on 
measured impact. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to