Re: Inserting heap tuples in bulk in COPY - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: Inserting heap tuples in bulk in COPY
Date
Msg-id CA+U5nMJGhB_5TQ_qksuPHSRO=a8scdCvEF8Qsq09XP8iQexyzA@mail.gmail.com
Whole thread Raw
In response to Inserting heap tuples in bulk in COPY  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: Inserting heap tuples in bulk in COPY
List pgsql-hackers
On Fri, Aug 12, 2011 at 8:16 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

> COPY is slow. Let's make it faster. One obvious optimization is to insert
> heap tuples in bigger chunks, instead of calling heap_insert() separately
> for every tuple. That saves the overhead of pinning and locking the buffer
> for every tuple, and you only need to write one WAL record for all the
> tuples written to the same page, instead of one for each tuple.

We don't pin the buffer for every tuple, that optimisation is already done...

When we discussed this before you said that it wasn't worth trying to
do this additional work - it was certainly a smaller gain than the one
we achieved by removing the pinning overhead.

Also, we discussed that you would work on buffering the index inserts,
which is where the main problem lies. The main heap is only a small
part of the overhead if we have multiple indexes already built on a
table - which is the use case that causes the most problem.

So I'm a little surprised to see you working on this and I'm guessing
that the COPY improvement with indexes is barely noticeable. This
would be a nice improvement, but not until the bulk index inserts are
done.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: Dimitri Fontaine
Date:
Subject: Re: Enforcing that all WAL has been replayed after restoring from backup
Next
From: Robert Haas
Date:
Subject: Re: index-only scans