This PR adds support for query rewriting optimizations that are oblivious to the cost model in Peloton.
Transitive predicates (optimized in OptimizeLoop)
Constant folding (optimized in PostgresParser).
We implement query rewrite rules using the current optimizer framework:
Transitive predicates: we implemented this rule by adding a new step to the beginning OptimizerLoop using a TopDownRewriter. We added rules to take predicates from nodes, generating all possible predicates by taking a transitive closure and add the new ones;
Trivial predicate simplification: we used the same framework as in the transitive predicates rewrite. This method removes trivial predicates like a = a, some of which are generated by the transitive predicates rule;
Constant folding can transform queries like select * from table where t.column1 = 3*(2-1) to select * from table where t.column1 = 3. These transformation are done in parser level instead of optimizer level because of implementation simplicity. And we don't really lose any information.
It support 3 type of constant folding
This PR adds support for query rewriting optimizations that are oblivious to the cost model in Peloton.
We implement query rewrite rules using the current optimizer framework:
Transitive predicates: we implemented this rule by adding a new step to the beginning OptimizerLoop using a TopDownRewriter. We added rules to take predicates from nodes, generating all possible predicates by taking a transitive closure and add the new ones;
Trivial predicate simplification: we used the same framework as in the transitive predicates rewrite. This method removes trivial predicates like
a = a
, some of which are generated by the transitive predicates rule;Constant folding can transform queries like
select * from table where t.column1 = 3*(2-1)
toselect * from table where t.column1 = 3
. These transformation are done in parser level instead of optimizer level because of implementation simplicity. And we don't really lose any information. It support 3 type of constant folding