Re: Memoize in between of two JOIN nodes

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Andrei Lepikhov <lepihov@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2025-03-07T01:13:27Z
Lists: pgsql-bugs
On Thu, Mar 6, 2025 at 8:17 PM Andrei Lepikhov <lepihov@gmail.com> wrote:
> Playing with memoisation, I found the case where the Memoize is put over
> a JOIN node (see attachment).
> I recall a discussion we had with Richard in which he mentioned [1] that
> this feature is still not implemented and is hard to design.
> I'm not sure, but may it be a sign of a potential bug?

In your case, the Memoize node is added on top of a base relation of a
subquery RTE, not a join relation.  The final plan might be kind of
confusing because the SubqueryScan node is considered trivial and is
removed from the plan tree.

Thanks
Richard