Re: Memoize ANTI and SEMI JOIN inner
Andrei Lepikhov <lepihov@gmail.com>
From: Andrei Lepikhov <lepihov@gmail.com>
To: Richard Guo <guofenglinux@gmail.com>, David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-03-31T09:46:08Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Enable use of Memoize for ANTI joins
- 0da29e4cb161 19 (unreleased) landed
On 3/31/25 11:03, Richard Guo wrote: > On Thu, Mar 20, 2025 at 3:02 PM David Rowley <dgrowleyml@gmail.com> wrote: >> For making this work, I think the attached should be about the guts of >> the code changes. I didn't look at the comments. Right now I can't >> think of any reason why this can't be done, but some experimentation >> might reveal some reason that it can't. > > I reviewed this patch and I have some concerns about the following > code: > > if (extra->inner_unique && > (inner_path->param_info == NULL || > bms_num_members(inner_path->param_info->ppi_serials) < > list_length(extra->restrictlist))) > return NULL; > > I understand that this check is used to ensure that the entire join > condition is parameterized in the case of unique joins, so that we can > safely mark the cache entry as complete after reading the first tuple. > However, ppi_clauses includes join clauses available from all outer > rels, not just the current outer rel, while extra->restrictlist only > includes the restriction clauses for the current join. This means the > check could pass even if a restriction clause isn't parameterized, as > long as another join clause, which doesn't belong to the current join, > is included in ppi_clauses. Initially, I had the same concern. But if ppi_clauses contains a qual, it should refer to this join and, as a result, be in the extra->restrictlist, isn't it? I thought about references to the other side of an OUTER JOIN, but if the subquery refers to LHS, it just not be transformed to the SEMI/ANTI join. Anyway, if you provide an example or just a sketch, I will be happy to discover it. -- regards, Andrei Lepikhov