Re: SQL MERGE is quite distinct from UPSERT - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: SQL MERGE is quite distinct from UPSERT
Date
Msg-id 20140720174028.GA13471@svana.org
Whole thread Raw
In response to SQL MERGE is quite distinct from UPSERT  (Peter Geoghegan <pg@heroku.com>)
Responses Re: SQL MERGE is quite distinct from UPSERT
List pgsql-hackers
On Sat, Jul 19, 2014 at 09:55:19PM -0700, Peter Geoghegan wrote:
> At a high level SQL MERGE is quite distinct from UPSERT, in that it is
> a utility command that performs inserts, updates and deletes while
> avoiding race conditions (e.g. unique constraint violations) on a more
> or less best effort basis. MERGE is conceptually messy. In contrast
> UPSERT is actually atomic, and having its behavior be relatively easy
> to reason about ought to be the top priority. There is a *really* big
> demand for UPSERT from users, not MERGE, although MERGE is certainly
> useful too.

FWIW, I agree. MERGE is hard enough as it is, but trying to guarentee
some kind of atomicity makes it nigh on impossible.  Indeed, after
reading what you wrote I think it may well be impossible to make it
atomic *and* make it perform in the general case.

So, +1 UPSERT.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.  -- Arthur Schopenhauer

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: bad estimation together with large work_mem generates terrible slow hash joins
Next
From: Tom Lane
Date:
Subject: Re: pg_stat_statements cluttered with "DEALLOCATE dbdpg_p*"