

Postgres upsert on duplicate and how other databases implement upsert - ditmer
http://michaelroders.tumblr.com/post/119356965581/postgres-upsert-on-duplicate-and-how-other

======
rockdoe
This doesn't actually go into the "implement" part. It just describes the
syntax.

The implementation is very hard and why it wasn't in Postgresql until now.

------
silon3
This needs some comment on proper usage (locking, isolation, ...) of these to
avoid deadlocks (one thread inserts, other updates at the same time, ...).
Without this this incomplete and of limited use.

------
craigkerstiens
This doesn't delve into the implementation, but does have a much deeper dive
of how it all works within Postgres -
[http://www.depesz.com/2015/05/10/waiting-for-9-5-add-
support...](http://www.depesz.com/2015/05/10/waiting-for-9-5-add-support-for-
insert-on-conflict-do-nothingupdate/)

------
baq
i'd like to see an explanation of why this syntax was chosen instead of ANSI
MERGE
([http://en.wikipedia.org/wiki/Merge_%28SQL%29](http://en.wikipedia.org/wiki/Merge_%28SQL%29)).

~~~
benhoyt
Looks like there's a thorough discussion of the pros and cons on the
PostgreSQL wiki here:
[https://wiki.postgresql.org/wiki/UPSERT#SQL_MERGE_syntax](https://wiki.postgresql.org/wiki/UPSERT#SQL_MERGE_syntax)

