Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0 - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0
Date
Msg-id 551A8E88.8030403@iki.fi
Whole thread Raw
In response to Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0  (Peter Geoghegan <pg@heroku.com>)
Responses Re: INSERT ... ON CONFLICT IGNORE (and UPDATE) 3.0
List pgsql-hackers
On 03/30/2015 07:20 PM, Peter Geoghegan wrote:
>
>> >* I think we should decouple the insertion and wal logging more. I think
>> >   the promise tuple insertion should be different from the final
>> >   insertion of the actual tuple. For one it seems cleaner to me, for
>> >   another it will avoid the uglyness around logical decoding. I think
>> >   also that the separation will make it more realistic to use something
>> >   like this for a COPY variant that doesn't raise unique violations and
>> >   such.
> Your COPY argument swung this for me. I'm looking into the implementation.

I'm pretty sceptical of that. ISTM you'll need to do modify the page 
twice for each insertion, first to insert the promise tuple, and then to 
turn the promise tuple into a real tuple. And WAL-log both updates. 
That's going to hurt performance.

To recover COPY from unique violations, you can just do the same as 
INSERT ON CONFLICT IGNORE does, and super-delete the inserted tuple on 
conflict. To recover from any random error, you'll need to abort the 
(sub)transaction anyway, and I don't see how it helps to separate the 
insertion of the promise tuple and the "finalization" of the insertion.

- Heikki




pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: WIP: SCRAM authentication
Next
From: Heikki Linnakangas
Date:
Subject: Re: Cleanup double semicolons at the end of source lines