Class JoinPushThroughJoinRule


  • public class JoinPushThroughJoinRule
    extends RelOptRule
    Rule that pushes the right input of a join into through the left input of the join, provided that the left input is also a join.

    Thus, (A join B) join C becomes (A join C) join B. The advantage of applying this rule is that it may be possible to apply conditions earlier. For instance,

    (sales as s join product_class as pc on true)
     join product as p
     on s.product_id = p.product_id
     and p.product_class_id = pc.product_class_id

    becomes

    (sales as s join product as p on s.product_id = p.product_id)
     join product_class as pc
     on p.product_class_id = pc.product_class_id

    Before the rule, one join has two conditions and the other has none (ON TRUE). After the rule, each join has one condition.