pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Tomas Vondra <tomas@2ndquadrant.com>
Subject: [PATCH 2/2] allocate BufFile eagerly
Date: Sat, 20 Apr 2019 21:59:37 +0200
---
src/backend/executor/nodeHash.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 7d36c22d61..7f125d8dba 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -915,6 +915,7 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
if (hashtable->innerBatchFile == NULL)
{
+ int i;
MemoryContext oldctx;
hashtable->fileCtx = AllocSetContextCreate(CurrentMemoryContext,
@@ -931,10 +932,20 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
/* time to establish the temp tablespaces, too */
PrepareTempTablespaces();
+ for (i = 1; i < nbatch; i++)
+ {
+ if (!hashtable->innerBatchFile[i])
+ hashtable->innerBatchFile[i] = BufFileCreateTemp(false);
+
+ if (!hashtable->outerBatchFile[i])
+ hashtable->outerBatchFile[i] = BufFileCreateTemp(false);
+ }
+
MemoryContextSwitchTo(oldctx);
}
else
{
+ int i;
MemoryContext oldctx;
oldctx = MemoryContextSwitchTo(hashtable->fileCtx);
@@ -949,6 +960,15 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
MemSet(hashtable->outerBatchFile + oldnbatch, 0,
(nbatch - oldnbatch) * sizeof(BufFile *));
+ for (i = 1; i < nbatch; i++)
+ {
+ if (!hashtable->innerBatchFile[i])
+ hashtable->innerBatchFile[i] = BufFileCreateTemp(false);
+
+ if (!hashtable->outerBatchFile[i])
+ hashtable->outerBatchFile[i] = BufFileCreateTemp(false);
+ }
+
MemoryContextSwitchTo(oldctx);
}
--
2.20.1
--73g6wg24zkedq45b--
Message-ID: <no-message-id-5652@localhost>
Permalink: ../no-message-id-5652@localhost/
Also on: postgresql.org/message-id/no-message-id-5652@localhost
copy link · copy postgr.es
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-performance@postgresql.org
Cc: tomas@2ndquadrant.com
Subject: Re: [PATCH 2/2] allocate BufFile eagerly
In-Reply-To: <no-message-id-5652@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