Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAhA7-0002Mj-1l for pgsql-general@arkaria.postgresql.org; Thu, 11 Oct 2018 20:02:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAhA5-0008Mo-6r for pgsql-general@arkaria.postgresql.org; Thu, 11 Oct 2018 20:02:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAhA4-0008Mh-RW for pgsql-general@lists.postgresql.org; Thu, 11 Oct 2018 20:02:20 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAh9y-0004u5-DL for pgsql-general@lists.postgresql.org; Thu, 11 Oct 2018 20:02:18 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 704E2202C; Thu, 11 Oct 2018 22:02:10 +0200 (CEST) Date: Thu, 11 Oct 2018 22:02:10 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: COPY threads Message-ID: <20181011200210.ldvty74xod7qw4zf@hjp.at> References: <065f5e56-5b25-0ce2-e20b-4305f71b2301@gmail.com> <20181010192440.cdxues44gcvx2sbi@alap3.anarazel.de> <7FCA0163-130B-474D-BE00-3BB5D2E0EC89@aol.com> <20181010210729.ewntjynvutnlgdn2@alap3.anarazel.de> <10F9B024-556C-4C8E-B8F5-9461A4696BCA@anarazel.de> <4382AB2D-744F-4A4C-B847-AC3556C2F80E@aol.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ojt2qr6ep64vumha" Content-Disposition: inline In-Reply-To: <4382AB2D-744F-4A4C-B847-AC3556C2F80E@aol.com> User-Agent: NeoMutt/20170113 (1.7.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --ojt2qr6ep64vumha Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-10-10 17:19:50 -0400, Ravi Krishna wrote: > > On Oct 10, 2018, at 17:18 , Andres Freund wrote: > > On October 10, 2018 2:15:19 PM PDT, Ravi Krishna w= rote: > >> 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. > >=20 > > Yes, you can. > >=20 > Thank you. Let me test it and see the benefit. We have a use case for th= is. 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/cla= udrin.2018-09-22/results.png 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. --=20 _ | 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 --ojt2qr6ep64vumha Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAlu/rD0ACgkQ8g5IURL+ KF0okhAAiRJV0iEXnClYDocx+ON3yxsYP9r215VgC2vnOoGNzvys9eAGZp9j0QNF c4PPe1oKnsGlGbl0TA25wIVkVc2XR/B0xvVPnDKtqRwL2lSMFA5gnSnsNfCTZZg6 I3yQnSfjsrx2r2i2LWtPH/JbERDN1eTPgKl/eze5jH9ZtmNsw2aS0VazL8cTO1mk hBse/YDVJgtvtQ61L9Prj8mLZXW+kmuK8PH/XOhu+bs0lFGsxP9IAsbtvtUf5qTx FTpryp2BxSZGjrxlRdI7QcvEBMt1AZ4i8GBI/WygCGU/+cz/rpQ4oTZmNBvbDhlU O/a3ve4LqI2QvAZoV3yXvmPz20s9uSbw/AwX04FflcN4adv98n9ThpTBlQnVLuTs B6Z8S8AOhCKEc0qVY7xpl0LHJfe1t3JCe376QOxVtvH0+41IUlS/UB+42JK2XtuA ViY1t+wnSjAwR9b4+8nCL9Vr1kIsvYM/RmbiCIXJBIHduvjcMtqfj47lS8fGTYPi u5u1A1rhfv9/rbJCtaF0VZsziyNFKo4kPz6Uyk9nMipeT1lh11RrNms+5HAjzhap dTaArtl/aXHglS0YmMt8bUbLcSylaj2Th/LPzPfN2ub9nWDjkVKuOE0QExhVSZ7b KFyeg/fuUsHEaSivzjdpGAedsU3j3mWOPaCV2xrpmGwHb41KETg= =ceen -----END PGP SIGNATURE----- --ojt2qr6ep64vumha--