2 ms·
Agreed - I think MERGE is great, but this post is missing the "Why not" part of the analysis. In the Postgres community, MERGE has been talked about for a long
by lfittl 4y ago
Agreed - I think MERGE is great, but this post is missing the "Why not" part of the analysis.
In the Postgres community, MERGE has been talked about for a long time, but in my understanding, part of the reason why the Postgres team initially shipped INSERT ... ON CONFLICT (instead of straight up MERGE) is that it lets you have guarantees about the outcome of the statement (i.e. either INSERT or UPDATE, by use of speculative insertion handling), vs MERGE can cause unique constraint violations and other issues.
AFAIK, the generic syntax of MERGE does not allow for stricter guarantees, and therefore there will always be cases where one is better than the other.