From: Justin Pryzby Date: Sat, 5 Dec 2020 08:52:14 -0600 Subject: [PATCH v8 3/4] COPY: flush multi-insert buffer based on accumulated size of tuples.. ..rather than line length --- src/backend/commands/copyfrom.c | 2 +- src/include/executor/nodeModifyTable.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c index c4fe75df8e..a8bbfcc71f 100644 --- a/src/backend/commands/copyfrom.c +++ b/src/backend/commands/copyfrom.c @@ -683,7 +683,7 @@ CopyFrom(CopyFromState cstate) /* Add this tuple to the tuple buffer */ MultiInsertInfoStore(&cstate->miinfo, resultRelInfo, myslot, - cstate->line_buf.len, + MemoryContextMemAllocated(myslot->tts_mcxt, true), cstate->miinfo.cur_lineno); /* diff --git a/src/include/executor/nodeModifyTable.h b/src/include/executor/nodeModifyTable.h index 71de7cf80e..e6bb27aade 100644 --- a/src/include/executor/nodeModifyTable.h +++ b/src/include/executor/nodeModifyTable.h @@ -41,10 +41,10 @@ extern void ExecReScanModifyTable(ModifyTableState *node); #define MAX_BUFFERED_TUPLES 1000 /* - * Flush buffers if there are >= this many bytes, as counted by the input - * size, of tuples stored. + * Flush buffers if there are >= this many bytes of tuples stored, as counted + * by the slot's memory contexts. */ -#define MAX_BUFFERED_BYTES 65535 +#define MAX_BUFFERED_BYTES (1024*1024*8) /* Trim the list of buffers back down to this number after flushing */ #define MAX_PARTITION_BUFFERS 32 -- 2.17.0 --AZuoSAvZwvV/ife4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v8-0004-WIP-check-tuple-size.patch"