pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Antonin Houska <ah@cybertec.at>
Subject: [PATCH] Attempt to reword a comment.
Date: Fri, 21 Aug 2026 10:21:20 +0200

In particular, the phrase "so every output row satisfies them" seems
problematic because an output row of a semijoin is NULL-extended, so the
output row usually does not satisfy the join clauses.
---
 src/backend/optimizer/path/uniquekeys.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/backend/optimizer/path/uniquekeys.c b/src/backend/optimizer/path/uniquekeys.c
index f9d9c37f447..34b2507d6b7 100644
--- a/src/backend/optimizer/path/uniquekeys.c
+++ b/src/backend/optimizer/path/uniquekeys.c
@@ -538,9 +538,14 @@ populate_joinrel_uniquekeys(PlannerInfo *root, RelOptInfo *joinrel,
 	if (jointype == JOIN_SEMI || jointype == JOIN_ANTI)
 	{
 		/*
-		 * A semijoin emits an LHS row only when some RHS row satisfied the
-		 * join clauses, so every output row satisfies them.  An antijoin
-		 * emits exactly the rows that no RHS row matched.
+		 * A semijoin emits a row only when the LHS satisfied the join clauses
+		 * (for at least one RHS row). Given that all the current unique keys
+		 * originate from the LHS, it's possible that rows having NULL in any
+		 * unique key attribute are filtered out by the join clauses.
+		 *
+		 * (An antijoin emits exactly the rows that do not satisfy the join
+		 * clauses, so rows having NULL in the unique key are not filtered
+		 * out.)
 		 */
 		if (jointype == JOIN_SEMI)
 			strengthen_uniquekeys_for_join(root, joinrel, restrictlist);
-- 
2.52.0


--=-=-=--






Message-ID: <no-message-id-1492244@localhost>
Permalink:  ../no-message-id-1492244@localhost/
Also on:    postgresql.org/message-id/no-message-id-1492244@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ah@cybertec.at
  Subject: Re: [PATCH] Attempt to reword a comment.
  In-Reply-To: <no-message-id-1492244@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox