0001-Prevent-Parallel-Hash-Join-for-JOIN_UNIQUE_INNER.patch
application/octet-stream
Filename: 0001-Prevent-Parallel-Hash-Join-for-JOIN_UNIQUE_INNER.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Prevent Parallel Hash Join for JOIN_UNIQUE_INNER.
| File | + | − |
|---|---|---|
| src/backend/optimizer/path/joinpath.c | 5 | 2 |
From e5791bdfe5f606c60fe7660916eb18959d4233a8 Mon Sep 17 00:00:00 2001
From: Thomas Munro <tmunro@postgresql.org>
Date: Tue, 18 Jun 2019 22:38:30 +1200
Subject: [PATCH] Prevent Parallel Hash Join for JOIN_UNIQUE_INNER.
WHERE EXISTS (...) queries cannot be executed by Parallel Hash Join
with jointype JOIN_UNIQUE_INNER, because there is no way to make a
partial plan totally unique. The consequence of allowing such plans
was duplicate results from some EXISTS queries.
Back-patch to 11. Bug #15857.
Author: Thomas Munro
Reported-by: Vladimir Kriukov
Discussion: https://postgr.es/m/15857-d1ba2a64bce0795e%40postgresql.org
---
src/backend/optimizer/path/joinpath.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index 501ad775cb..94dbfd8f85 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -1867,9 +1867,12 @@ hash_inner_and_outer(PlannerInfo *root,
/*
* Can we use a partial inner plan too, so that we can build a
- * shared hash table in parallel?
+ * shared hash table in parallel? We can't handle
+ * JOIN_UNIQUE_INNER because we can't guarantee uniqueness.
*/
- if (innerrel->partial_pathlist != NIL && enable_parallel_hash)
+ if (save_jointype != JOIN_UNIQUE_INNER &&
+ innerrel->partial_pathlist != NIL &&
+ enable_parallel_hash)
{
cheapest_partial_inner =
(Path *) linitial(innerrel->partial_pathlist);
--
2.21.0