Building on the work of
IMPALA-2805, we can use the cost and selectivity estimates to reorder conjuncts within a compound predicate, whereas currently we only reorder conjuncts that end up as different exprs.
For example, in the query:
select * from tpch.lineitem where (p_container like '%MED%' or p_size = 1) and p_partkey = 0
Current;y we are able to recognize that 'p_partkey = 0' is cheaper than '(p_container like '%MED%' or p_size = 1)' and switch their order. We could get even more of a speedup by recognizing that 'p_size = 1' is cheaper than 'p_container like '%MED&'' and also reorder them within the compound predicate.