On Thu, Dec 7, 2017 at 5:11 AM, David Rowley <david.row...@2ndquadrant.com> wrote: > > While rebasing this today I also noticed that we won't properly detect > unique joins in add_paths_to_joinrel() as we're still testing for > uniqueness against the partitioned parent rather than the only child. > This is likely not a huge problem since we'll always get a false > negative and never a false positive, but it is a missing optimisation. > I've not thought of how to solve it yet, it's perhaps not worth going > to too much trouble over. >
It's only the jointrelids that are parent's relids, but all the following tests for unique join use RelOptInfo::relids which are child relids. case JOIN_UNIQUE_INNER: extra.inner_unique = bms_is_subset(sjinfo->min_lefthand, outerrel->relids); break; case JOIN_UNIQUE_OUTER: extra.inner_unique = innerrel_is_unique(root, outerrel->relids, innerrel, JOIN_INNER, restrictlist, false); break; default: extra.inner_unique = innerrel_is_unique(root, outerrel->relids, innerrel, jointype, restrictlist, false); break; Do you have a testcase, which shows the problem? -- Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company