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

From Robert Haas
Subject Re: Inserting heap tuples in bulk in COPY
Date
Msg-id CA+TgmobMw0SbDysnyw05NTViWZGrv3DL+_7innH7HP=N3M44ig@mail.gmail.com
Whole thread Raw
In response to Re: Inserting heap tuples in bulk in COPY  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Inserting heap tuples in bulk in COPY
Re: Inserting heap tuples in bulk in COPY
List pgsql-hackers
On Tue, Aug 7, 2012 at 4:52 PM, Simon Riggs <simon@2ndquadrant.com> wrote:
> Incidentally, we can also optimise repeated inserts within a normal
> transaction using this method, by implementing deferred unique
> constraints. At present we say that unique constraints aren't
> deferrable, but there's no reason they can't be, if we allow buffering
> in the index. (Implementing a deferred constraint that won't fail if
> we do UPDATE foo SET pk = pk+1 requires a buffer the size of foo,
> which is probably a bad plan, plus you'd need to sort the inputs, so
> that particular nut is another issue altogether, AFAICS).

We've had deferrable unique constraints since 9.0, courtesy of Dean Rasheed.

> I think we need to implement buffering both to end of statement or end
> of transaction, not just one or the other.

Another (not necessarily better) idea is to use a buffer that's part
of the index, like the GIN fastupdate stuff, so that there's no
particular constraint on when the buffer has to be flushed, but
competing index scans may be slower until it is.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Git diff patch in context diff format
Next
From: Simon Riggs
Date:
Subject: Re: Inserting heap tuples in bulk in COPY