Re: Feature suggestion: ON CONFLICT DO NOTHING RETURNING which returns existing row data - Mailing list pgsql-hackers

From Tom Dunstan
Subject Re: Feature suggestion: ON CONFLICT DO NOTHING RETURNING which returns existing row data
Date
Msg-id 25247983-2BB2-4B2F-86E7-C9F313278F81@tomd.cc
Whole thread Raw
In response to Re: Feature suggestion: ON CONFLICT DO NOTHING RETURNING which returns existing row data  (Pantelis Theodosiou <ypercube@gmail.com>)
List pgsql-hackers
> On 5 Oct 2016, at 8:11 PM, Pantelis Theodosiou <ypercube@gmail.com> wrote:
>
> This can be solved by chaining modifying CTEs.
>
> Something like this (not tested)  that can work with multiple rows inserted:

Thanks for the suggestion, but it was actually slower than our current implementation, I believe due to always looking
upt1’s id in that join rather than only doing it when we didn’t get an id back from the insert. My hope with this
featuresuggestion / request was that we wouldn’t have to do that subsequent lookup at all, as pg would just give it
backto us. 

Maybe it would be a win if we were inserting multiple rows, but this code is actually in a trigger on a dummy table
thatwe COPY data in to - thus it can’t be rewritten as a rule or a multi-row insert like that. 

Thanks

Tom




pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: Declarative partitioning - another take
Next
From: Masahiko Sawada
Date:
Subject: Re: Transactions involving multiple postgres foreign servers