JoinCommuteRule and JoinAssociateRule form a complete ruleset to generate all bushy trees (plus join-project transposes to counter new projects created during commute).
These rules do not check whether the new join trees contain an always TRUE condition which is a cross-product. Such join trees are not optimal in the majority of cases, and practical optimizers might want to suppress them.
In this ticket, I propose to add a configuration property to JoinCommuteRule and JoinAssociateRule to disable the creation of trees with always TRUE condition:
- The property should be disabled by default because sometimes cross-products might be present in the query on purpose (e.g., see https://dl.acm.org/doi/10.5555/645916.671976, page 315)
- We consider the "always TRUE" condition only, even though they represent only part of cross-products. The reason is that it might be difficult and expensive to understand whether the condition is cross-join or not (e.g., for hypergraphs). On the other hand, the check for "always true" is cheap and robust. We assume that the user might need to do some pre-processing (e.g., filter push-down) to take advantage of the new property.
- We do not extend the JoinPushThroughJoinRule for now, since the [commute + associate] ruleset already explores all bushy trees and testing of the new property for JoinPushThroughJoinRule is difficult. We may extend this rule in a separate ticket if needed.