3 ms·
I really miss "REPLACE INTO". Upserts are a complete mess on postgres. It requires 3-5 queries to get the same behavior.
by jcampbell1 14y ago
I really miss "REPLACE INTO". Upserts are a complete mess on postgres. It requires 3-5 queries to get the same behavior.
- viraptor 14y agoMaybe I'm missing something, but doesn't it do the same as `IF EXISTS(SELECT ...) THEN UPDATE ... ELSE INSERT ... END`, so 2 queries actually executed? What cases does it not cover?
- fdr 14y agoThis is a procedural function, which is a pain in the butt, and slow. MERGE support has been a want-to-have for a long time. Unfortunately Postgres is stuck between the complex but useful behavior of implementing MERGE (without destroying concurrency) and the simpler and still-useful MySQL extension "OR REPLACE". Although it seems like some people have floated the idea of going with the simpler non-standard option without being shot down, it seems like the people interested in doing the work are most interested in implementing the complex and more featureful standardized option, and it's rather difficult, so there is no MERGE yet.