From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Improve COPY performance into table with indexes.
Date: Fri, 3 Apr 2020 10:08:04 -0600
Message-ID: <87083802-1fb6-52c9-b651-fdfdbe1232a2@gmail.com> (raw)
In-Reply-To: <fb5477a3-c46a-e7f1-433c-444774942f31@aklaver.com>
References: <CAFCW2QMNCxO8=8FE5r05KqSDJAun-E0-gx174YhkTfVRMhTz1w@mail.gmail.com>
<fb5477a3-c46a-e7f1-433c-444774942f31@aklaver.com>
On 4/3/20 9:52 AM, Adrian Klaver wrote:
> On 4/2/20 9:42 PM, James Brauman wrote:
>> I am using the COPY command to insert 10 million rows from a CSV file
>> into a database table and I am finding the performance is
>> unacceptable. When the COPY command is executed the disk I/O is
>> extremely high which leads to degraded query performance for other
>> queries being executed on the database.
>>
>> I have tried removing the indexes from the database table and this
>> dramatically improved performance (both reducing the execution time
>> and reducing disk I/O).
>
I've had excellent results dealing similar data quantity with the
earlier suggestion of writing to a staging table. Simply splitting the
insert statements to cover 1/16[1] of the data turned untenable into
real-time.
[1] I split on an id column which is of UUID type. Any arbitrary
splitting that reduces the footprint sufficiently will do.
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: robjsargent@gmail.com
Subject: Re: Improve COPY performance into table with indexes.
In-Reply-To: <87083802-1fb6-52c9-b651-fdfdbe1232a2@gmail.com>
References: <CAFCW2QMNCxO8=8FE5r05KqSDJAun-E0-gx174YhkTfVRMhTz1w@mail.gmail.com> <fb5477a3-c46a-e7f1-433c-444774942f31@aklaver.com> <87083802-1fb6-52c9-b651-fdfdbe1232a2@gmail.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