pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: COPY threads
Date: Thu, 11 Oct 2018 22:02:10 +0200
Message-ID: <20181011200210.ldvty74xod7qw4zf@hjp.at> (raw)
In-Reply-To: <4382AB2D-744F-4A4C-B847-AC3556C2F80E@aol.com>
References: <065f5e56-5b25-0ce2-e20b-4305f71b2301@gmail.com>
	<d198d930f6c764c8c8667023fc2de333e02ddf46.camel@cybertec.at>
	<20181010192440.cdxues44gcvx2sbi@alap3.anarazel.de>
	<B732777C-37FC-484A-A84B-6A7C20D4D2B5@aol.com>
	<CAFNqd5UMtCNiHsMLkirywcZC=QOE=ThEy1ABn6-+rVC5j73g3Q@mail.gmail.com>
	<7FCA0163-130B-474D-BE00-3BB5D2E0EC89@aol.com>
	<20181010210729.ewntjynvutnlgdn2@alap3.anarazel.de>
	<C61F9A0D-477C-4F9D-8C1E-2B6CBBEF7C99@aol.com>
	<10F9B024-556C-4C8E-B8F5-9461A4696BCA@anarazel.de>
	<4382AB2D-744F-4A4C-B847-AC3556C2F80E@aol.com>

On 2018-10-10 17:19:50 -0400, Ravi Krishna wrote:
> > On Oct 10, 2018, at 17:18 , Andres Freund <andres@anarazel.de> wrote:
> > On October 10, 2018 2:15:19 PM PDT, Ravi Krishna <srkrishna1@aol.com> wrote:
> >> If I have a large file with say 400 million rows, can I first split it
> >> into 10 files of 40 million rows each and then fire up 10 different
> >> COPY sessions , each reading from a split file, but copying into the
> >> same table.  I thought not.  It will be great if we can do this.
> > 
> > Yes, you can.
> > 
> Thank you.  Let me test it and see the benefit. We have a use case for this.

You should of course test this on your own hardware with your own data,
but here are the results of a simple benchmark (import 1 million rows
into a table without indexes via different methods) I ran a few weeks
ago on one of our servers:

https://github.com/hjp/dbbench/blob/master/import_pg_comparison/results/claudrin.2018-09-22/results....

y axis is rows per second. x axis are different runs, sorted from
slowest to fastest (so 2 is the median).

As you can see it doesn't parallelize perfectly: 2 copy processes are
only about 50 % faster than 1, and 4 are about 33 % faster than 2. But
there is a still quite a respectable performance boost.

        hp

PS: The script is of course in the same repo, but I didn't include the
test data because I don't think I'm allowed to include that.

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp@hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (16+ messages)  latest in thread

Message-ID: <20181011200210.ldvty74xod7qw4zf@hjp.at>
Permalink:  ../20181011200210.ldvty74xod7qw4zf@hjp.at/
Also on:    postgresql.org/message-id/20181011200210.ldvty74xod7qw4zf@hjp.at

 · 

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: hjp-pgsql@hjp.at
  Subject: Re: COPY threads
  In-Reply-To: <20181011200210.ldvty74xod7qw4zf@hjp.at>
  References: <065f5e56-5b25-0ce2-e20b-4305f71b2301@gmail.com> <d198d930f6c764c8c8667023fc2de333e02ddf46.camel@cybertec.at> <20181010192440.cdxues44gcvx2sbi@alap3.anarazel.de> <B732777C-37FC-484A-A84B-6A7C20D4D2B5@aol.com> <CAFNqd5UMtCNiHsMLkirywcZC=QOE=ThEy1ABn6-+rVC5j73g3Q@mail.gmail.com> <7FCA0163-130B-474D-BE00-3BB5D2E0EC89@aol.com> <20181010210729.ewntjynvutnlgdn2@alap3.anarazel.de> <C61F9A0D-477C-4F9D-8C1E-2B6CBBEF7C99@aol.com> <10F9B024-556C-4C8E-B8F5-9461A4696BCA@anarazel.de> <4382AB2D-744F-4A4C-B847-AC3556C2F80E@aol.com> <20181011200210.ldvty74xod7qw4zf@hjp.at>

* 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