I try to answer the first question. The materialized view rewriting of `SubstitutionVisitor` is based on the equivalent replacement of relational algebra expressions. Disadvantages of it are explained on the website [1]. 1. it might need to enumerate exhaustively all possible equivalent rewritings for a given expression to find a materialized view substitution. 2. is not scalable in the presence of complex views
The second way , `MaterializedViewRule`, is implemented and extended from the algorithm described in [GL01]. Its implementation method extracts the structure of the query (predicate information, column information, etc.), and then perform a series of verifications (detail was in [GL01] )and determine whether to rewrite, generate Compensation Predicate and completes the rewrite. This is a A more advanced way. The scope of applicability of this rewrite algorithm is wider than that of the first one. In addition, as you can see from the code, `MaterializedViewSubstitutionVisitor` is ready to be discarded. If there is any misunderstanding, please correct me~ [1] https://calcite.apache.org/docs/materialized_views.html#substitution-via-rules-transformation > 2022年1月21日 上午10:12,徐保荣 <luchen...@aloudata.com> 写道: > > hello, > This problems keeps making me puzzled. > > question1: what is the differences between the two implemenrations of > view-based query rewriting?Advantages and disadvantages > based on view substitution( SubstitutionVisitor、rules:unifyrule) > Rewriting using plan structural information(rules:MaterializedViewRule) > > question2: Is there some materialized rewriting example where the first one > not work but the second work? if can list , very thanks > > I look forward to hearing from you very much > thanks > > > > > > rules transformation > Permalink > >