aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2020-01-27 12:52:08 +1300
committerThomas Munro <tmunro@postgresql.org>2020-01-27 14:11:24 +1300
commitf9d0be241aacc4913302080594f5a342b8b9dc15 (patch)
tree3f9fefedf0e3029f0e04b4681e64300446258477
parentbad494380210a76071485c5d8624334c4389dd88 (diff)
downloadpostgresql-f9d0be241aacc4913302080594f5a342b8b9dc15.tar.gz
postgresql-f9d0be241aacc4913302080594f5a342b8b9dc15.zip
Avoid unnecessary shm writes in Parallel Hash Join.
Currently, Parallel Hash Join cannot be used for full/right joins, so there is no point in setting the match flag. It turns out that the cache coherence traffic generated by those writes slows down large systems running many-core joins, so let's stop doing that. In future, if we need to use match bits in parallel joins, we might want to consider setting them only if not already set. Back-patch to 11, where Parallel Hash Join arrived. Reported-by: Deng, Gang Discussion: https://postgr.es/m/0F44E799048C4849BAE4B91012DB910462E9897A%40SHSMSX103.ccr.corp.intel.com
-rw-r--r--src/backend/executor/nodeHashjoin.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index ec37558c127..c563fa4bbca 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -454,7 +454,26 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel)
if (joinqual == NULL || ExecQual(joinqual, econtext))
{
node->hj_MatchedOuter = true;
- HeapTupleHeaderSetMatch(HJTUPLE_MINTUPLE(node->hj_CurTuple));
+
+ if (parallel)
+ {
+ /*
+ * Full/right outer joins are currently not supported
+ * for parallel joins, so we don't need to set the
+ * match bit. Experiments show that it's worth
+ * avoiding the shared memory traffic on large
+ * systems.
+ */
+ Assert(!HJ_FILL_INNER(node));
+ }
+ else
+ {
+ /*
+ * This is really only needed if HJ_FILL_INNER(node),
+ * but we'll avoid the branch and just set it always.
+ */
+ HeapTupleHeaderSetMatch(HJTUPLE_MINTUPLE(node->hj_CurTuple));
+ }
/* In an antijoin, we never return a matched tuple */
if (node->js.jointype == JOIN_ANTI)