pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Implement support for bulk inserts in postgres_fdw
Date: Wed, 20 Jan 2021 22:58:50 +0000
Message-ID: <E1l2MR8-0005o9-4O@gemulon.postgresql.org> (raw)

Implement support for bulk inserts in postgres_fdw

Extends the FDW API to allow batching inserts into foreign tables. That
is usually much more efficient than inserting individual rows, due to
high latency for each round-trip to the foreign server.

It was possible to implement something similar in the regular FDW API,
but it was inconvenient and there were issues with reporting the number
of actually inserted rows etc. This extends the FDW API with two new
functions:

* GetForeignModifyBatchSize - allows the FDW picking optimal batch size

* ExecForeignBatchInsert - inserts a batch of rows at once

Currently, only INSERT queries support batching. Support for DELETE and
UPDATE may be added in the future.

This also implements batching for postgres_fdw. The batch size may be
specified using "batch_size" option both at the server and table level.

The initial patch version was written by me, but it was rewritten and
improved in many ways by Takayuki Tsunakawa.

Author: Takayuki Tsunakawa
Reviewed-by: Tomas Vondra, Amit Langote
Discussion: https://postgr.es/m/20200628151002.7x5laxwpgvkyiu3q@development

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b663a4136331de6c7364226e3dbf7c88bfee7145

Modified Files
--------------
contrib/postgres_fdw/deparse.c                 |  54 +++-
contrib/postgres_fdw/expected/postgres_fdw.out | 155 +++++++++++-
contrib/postgres_fdw/option.c                  |  14 ++
contrib/postgres_fdw/postgres_fdw.c            | 329 ++++++++++++++++++++-----
contrib/postgres_fdw/postgres_fdw.h            |   5 +-
contrib/postgres_fdw/sql/postgres_fdw.sql      |  93 +++++++
doc/src/sgml/fdwhandler.sgml                   |  89 ++++++-
doc/src/sgml/postgres-fdw.sgml                 |  13 +
src/backend/executor/execPartition.c           |  17 ++
src/backend/executor/nodeModifyTable.c         | 160 ++++++++++++
src/backend/nodes/list.c                       |  15 ++
src/include/foreign/fdwapi.h                   |  10 +
src/include/nodes/execnodes.h                  |   6 +
src/include/nodes/pg_list.h                    |  15 ++
14 files changed, 903 insertions(+), 72 deletions(-)



Message-ID: <E1l2MR8-0005o9-4O@gemulon.postgresql.org>
Permalink:  ../E1l2MR8-0005o9-4O@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1l2MR8-0005o9-4O@gemulon.postgresql.org

 · 

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 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: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Implement support for bulk inserts in postgres_fdw
  In-Reply-To: <E1l2MR8-0005o9-4O@gemulon.postgresql.org>
  References: <E1l2MR8-0005o9-4O@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