I wrote: > I wondered why, instead of inventing an extra semantics-modifying flag, > we couldn't just change the jointype to *be* JOIN_SEMI when we've > discovered that the inner side is unique.
BTW, to clarify: I'm not imagining that we'd make this change in the query jointree, as for example prepjointree.c might do. That would appear to add join order constraints, which we don't want. But I'm thinking that at the instant where we form a join Path, we could change the Path's jointype to be JOIN_SEMI or JOIN_SEMI_OUTER if we're able to prove the inner side unique, rather than annotating the Path with a separate flag. Then that representation is what propagates forward. It seems like the major intellectual complexity here is to figure out how to detect inner-side-unique at reasonable cost. I see that for LEFT joins you're caching that in the SpecialJoinInfos, which is probably fine. But for INNER joins it looks like you're just doing it over again for every candidate join, and that seems mighty expensive. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers