On Wed, Jun 19, 2024 at 12:49 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Richard Guo <guofenglinux@gmail.com> writes:
> > It seems to me that the new operator is somewhat artificial, since it is
> > designed to support a mergejoin but lacks a valid commutator. So before
> > we proceed to discuss the fix, I'd like to know whether this is a valid
> > issue that needs fixing.
> I do not think we should add a great deal of complexity or extra
> planner cycles to deal with this; but if it can be fixed at low
> cost, we should.
I think we can simply verify the validity of commutators for clauses in
the form "inner op outer" when selecting mergejoin/hash clauses. If a
clause lacks a commutator, we should consider it unusable for the given
pair of outer and inner rels. Please see the attached patch.
Thanks
Richard