From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: tableam: Add table_multi_insert() and revamp/speed-up COPY FROM
Date: Thu, 04 Apr 2019 23:31:16 +0000
Message-ID: <E1hCBpE-0005Ib-9C@gemulon.postgresql.org> (raw)
tableam: Add table_multi_insert() and revamp/speed-up COPY FROM buffering.
This adds table_multi_insert(), and converts COPY FROM, the only user
of heap_multi_insert, to it.
A simple conversion of COPY FROM use slots would have yielded a
slowdown when inserting into a partitioned table for some
workloads. Different partitions might need different slots (both slot
types and their descriptors), and dropping / creating slots when
there's constant partition changes is measurable.
Thus instead revamp the COPY FROM buffering for partitioned tables to
allow to buffer inserts into multiple tables, flushing only when
limits are reached across all partition buffers. By only dropping
slots when there've been inserts into too many different partitions,
the aforementioned overhead is gone. By allowing larger batches, even
when there are frequent partition changes, we actuall speed such cases
up significantly.
By using slots COPY of very narrow rows into unlogged / temporary
might slow down very slightly (due to the indirect function calls).
Author: David Rowley, Andres Freund, Haribabu Kommi
Discussion:
https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.dehttps://postgr.es/m/20190327054923.t3epfuewxfqdt22e@alap3.anarazel.de
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/86b85044e823a304d2a265abc030254d39efe7df
Modified Files
--------------
src/backend/access/heap/heapam.c | 23 +-
src/backend/access/heap/heapam_handler.c | 1 +
src/backend/commands/copy.c | 888 +++++++++++++++++++------------
src/backend/executor/execMain.c | 1 +
src/backend/executor/execPartition.c | 1 +
src/include/access/heapam.h | 6 +-
src/include/access/tableam.h | 26 +
src/include/nodes/execnodes.h | 4 +
src/tools/pgindent/typedefs.list | 3 +
9 files changed, 587 insertions(+), 366 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de
Subject: Re: pgsql: tableam: Add table_multi_insert() and revamp/speed-up COPY FROM
In-Reply-To: <E1hCBpE-0005Ib-9C@gemulon.postgresql.org>
References: <E1hCBpE-0005Ib-9C@gemulon.postgresql.org>
* 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