From: | Richard Guo <rguo(at)postgresql(dot)org> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Enable use of Memoize for ANTI joins |
Date: | 2025-07-03 01:58:45 |
Message-ID: | E1uX9Dp-004RNE-2f@gemulon.postgresql.org |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Enable use of Memoize for ANTI joins
Currently, we do not support Memoize for SEMI and ANTI joins because
nested loop SEMI/ANTI joins do not scan the inner relation to
completion, which prevents Memoize from marking the cache entry as
complete. One might argue that we could mark the cache entry as
complete after fetching the first inner tuple, but that would not be
safe: if the first inner tuple and the current outer tuple do not
satisfy the join clauses, a second inner tuple matching the parameters
would find the cache entry already marked as complete.
However, if the inner side is provably unique, this issue doesn't
arise, since there would be no second matching tuple. That said, this
doesn't help in the case of SEMI joins, because a SEMI join with a
provably unique inner side would already have been reduced to an inner
join by reduce_unique_semijoins.
Therefore, in this patch, we check whether the inner relation is
provably unique for ANTI joins and enable the use of Memoize in such
cases.
Author: Richard Guo <guofenglinux(at)gmail(dot)com>
Reviewed-by: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
Reviewed-by: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAMbWs48FdLiMNrmJL-g6mDvoQVt0yNyJAqMkv4e2Pk-5GKCZLA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/0da29e4cb161f78a5ef534b3fb4467756a422e25
Modified Files
--------------
src/backend/optimizer/path/joinpath.c | 47 ++++++++++++++-------------
src/test/regress/expected/memoize.out | 60 +++++++++++++++++++++++++++++++++++
src/test/regress/sql/memoize.sql | 27 ++++++++++++++++
3 files changed, 112 insertions(+), 22 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2025-07-03 02:24:03 | pgsql: Improve checks for GUC recovery_target_timeline |
Previous Message | Michael Paquier | 2025-07-02 23:42:11 | pgsql: Add InjectionPointList() to retrieve list of injection points |