MemoizePath fails to work for partitionwise join - Mailing list pgsql-hackers

From Richard Guo
Subject MemoizePath fails to work for partitionwise join
Date
Msg-id CAMbWs48GkNom272sfp0-WeD6_0HSR19BJ4H1c9ZKSfbVnJsvRg@mail.gmail.com
Whole thread Raw
Responses Re: MemoizePath fails to work for partitionwise join  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I happened to notice that currently MemoizePath cannot be generated for
partitionwise join.  I traced that and have found the problem.  One
condition we need to meet to generate MemoizePath is that inner path's
ppi_clauses should have the form "outer op inner" or "inner op outer",
as checked by clause_sides_match_join in paraminfo_get_equal_hashops.

Note that when are at this check, the inner path has not got the chance
to be re-parameterized (that is done later in try_nestloop_path), so if
it is parameterized, it is parameterized by the topmost parent of the
outer rel, not the outer rel itself.  Thus this check performed by
clause_sides_match_join could not succeed if we are joining two child
rels.

The fix is straightforward, just to use outerrel->top_parent if it is
not null and leave the reparameterization work to try_nestloop_path.  In
addition, I believe when reparameterizing MemoizePath we need to adjust
its param_exprs too.

Attach the patch for fix.

Thanks
Richard
Attachment

pgsql-hackers by date:

Previous
From: John Naylor
Date:
Subject: Re: slab allocator performance issues
Next
From: Amit Kapila
Date:
Subject: Re: Avoid streaming the transaction which are skipped (in corner cases)