pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mats Julian Olsen <mats@duneanalytics.com>
To: pabloa98 <pabloa98@gmail.com>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: wilhelm@duneanalytics.com
Subject: Re: postgres_fdw insert extremely slow
Date: Fri, 27 Nov 2020 13:40:48 +0100
Message-ID: <19cbedea-d24f-6fcc-0c16-06f8adf76e37@duneanalytics.com> (raw)
In-Reply-To: <CAEjudX452F-MezbU6gauHaPx8EUkrafsnuuuCJD52ifiHkK5Ag@mail.gmail.com>
References: <CAARtqpE-7mZY8WKKMq2fWeHBcrAJu41_GnKgKqdvkidk7g+M3A@mail.gmail.com>
	<3862aa4d-01c7-c76b-4497-ebce1af702cc@aklaver.com>
	<10df210c-a1bb-f909-9a48-61ac54880df0@duneanalytics.com>
	<493978.1606323509@sss.pgh.pa.us>
	<a5d9aeaa-83bf-457a-e04c-b6a66bee306f@duneanalytics.com>
	<494596.1606324345@sss.pgh.pa.us>
	<56a2c3cf-374d-893b-2feb-964805ff0884@duneanalytics.com>
	<500774.1606331937@sss.pgh.pa.us>
	<c44acaac-ed91-2b1d-043e-a6570d392caa@aklaver.com>
	<35a8b025f52641b6d60c432c0d1259eb64b07664.camel@cybertec.at>
	<CAEjudX452F-MezbU6gauHaPx8EUkrafsnuuuCJD52ifiHkK5Ag@mail.gmail.com>

On 27.11.2020 10:11, pabloa98 wrote:
>
>
> On Thu, Nov 26, 2020 at 8:25 PM Laurenz Albe <laurenz.albe@cybertec.at 
> <mailto:laurenz.albe@cybertec.at>> wrote:
>
>     On Thu, 2020-11-26 at 09:07 -0800, Adrian Klaver wrote:
>     > So even if Mats where to break this query:
>     >
>     > INSERT INTO foreign.labels (address, labels)
>     > SELECT address_id, ARRAY_AGG(name) AS labels
>     > FROM labels
>     > GROUP BY 1
>     > LIMIT 100;
>     >
>     > down into something like this:
>     >
>     > INSERT INTO foreign.labels (address, labels)
>     > VALUES (), (), (), ();
>     >
>     > postgres_fdw would send it as individual INSERTs?
>
>     Yes, that's the way the FDW API works.
>
> I can confirm that it is NOT like FDW API work. I have the same 
> problem and in the fdw database it receives:
>
> INSERT INTO foreign.labels (address, labels) VALUES ();
>
> One value at a time.
>
> Same scenario, same performance. No network related. It is just a 
> batch insert is split into 1 insert by row.
>
>
> Pablo

Thank you all for your replies.

We've decided not to use postgres_fdw for the time being because of this 
behavior. Hope to revisit in the future.

Best,

-- 
Mats
CTO @ Dune Analytics
We're hiring: https://careers.duneanalytics.com

view thread (17+ messages)  latest in thread

Message-ID: <19cbedea-d24f-6fcc-0c16-06f8adf76e37@duneanalytics.com>
Permalink:  ../19cbedea-d24f-6fcc-0c16-06f8adf76e37@duneanalytics.com/
Also on:    postgresql.org/message-id/19cbedea-d24f-6fcc-0c16-06f8adf76e37@duneanalytics.com

 · 

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-general@postgresql.org
  Cc: mats@duneanalytics.com, pabloa98@gmail.com, laurenz.albe@cybertec.at, adrian.klaver@aklaver.com, tgl@sss.pgh.pa.us, wilhelm@duneanalytics.com
  Subject: Re: postgres_fdw insert extremely slow
  In-Reply-To: <19cbedea-d24f-6fcc-0c16-06f8adf76e37@duneanalytics.com>
  References: <CAARtqpE-7mZY8WKKMq2fWeHBcrAJu41_GnKgKqdvkidk7g+M3A@mail.gmail.com> <3862aa4d-01c7-c76b-4497-ebce1af702cc@aklaver.com> <10df210c-a1bb-f909-9a48-61ac54880df0@duneanalytics.com> <493978.1606323509@sss.pgh.pa.us> <a5d9aeaa-83bf-457a-e04c-b6a66bee306f@duneanalytics.com> <494596.1606324345@sss.pgh.pa.us> <56a2c3cf-374d-893b-2feb-964805ff0884@duneanalytics.com> <500774.1606331937@sss.pgh.pa.us> <c44acaac-ed91-2b1d-043e-a6570d392caa@aklaver.com> <35a8b025f52641b6d60c432c0d1259eb64b07664.camel@cybertec.at> <CAEjudX452F-MezbU6gauHaPx8EUkrafsnuuuCJD52ifiHkK5Ag@mail.gmail.com> <19cbedea-d24f-6fcc-0c16-06f8adf76e37@duneanalytics.com>

* 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