From: Justin Pryzby Date: Sat, 5 Dec 2020 08:52:14 -0600 Subject: [PATCH v9 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 8221a2c5d3..e5ea909dfe 100644 --- a/src/backend/commands/copyfrom.c +++ b/src/backend/commands/copyfrom.c @@ -685,7 +685,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 30542a542a..87b689099c 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 --3yNHWXBV/QO9xKNm Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v9-0004-WIP-check-tuple-size.patch"