On Thu, Aug 29, 2019 at 3:15 PM Richard Guo <ri...@pivotal.io> wrote: > > > Attached is a patch as an attempt to address this issue. The idea is > quite straightforward. When building partition info for joinrel, we > generate any possible EC-derived joinclauses of form 'outer_em = > inner_em', which will be used together with the original restrictlist to > check if there exists an equi-join condition for each pair of partition > keys. > > Any comments are welcome! /* + * generate_join_implied_equalities_for_all + * Create any EC-derived joinclauses of form 'outer_em = inner_em'. + * + * This is used when building partition info for joinrel. + */ +List * +generate_join_implied_equalities_for_all(PlannerInfo *root, + Relids join_relids, + Relids outer_relids, + Relids inner_relids)
I think we need to have more detailed comments about why we need this separate function, we can also explain that generate_join_implied_equalities function will avoid the join clause if EC has the constant but for partition-wise join, we need that clause too. + while ((i = bms_next_member(matching_ecs, i)) >= 0) + { + EquivalenceClass *ec = (EquivalenceClass *) list_nth(root->eq_classes, i); + List *outer_members = NIL; + List *inner_members = NIL; + ListCell *lc1; + + /* Do not consider this EC if it's ec_broken */ + if (ec->ec_broken) + continue; + + /* Single-member ECs won't generate any deductions */ + if (list_length(ec->ec_members) <= 1) + continue; + I am wondering isn't it possible to just process the missing join clause? I mean 'generate_join_implied_equalities' has only skipped the ECs which has const so can't we create join clause only for those ECs and append it the "Restrictlist" we already have? I might be missing something? -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com