top | item 9575532

Postgres upsert on duplicate and how other databases implement upsert

33 points| ditmer | 10 years ago |michaelroders.tumblr.com

7 comments

order
[+] rockdoe|10 years ago|reply
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|10 years ago|reply
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.
[+] baq|10 years ago|reply
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).
[+] swsieber|10 years ago|reply
The semantics are slightly different - the Postgres command doesn't do the exact same thing. So rather have two identically named commands that do slightly different things, they picked a different syntax so it would be clear they aren't the same.