Re:One word in PostgreSQL unlocked a 9x performance improvement
by OJFord on Sunday June 14, 2020 @02:31PM
(#23520013)
Is it? Returning the conflicts that weren't inserted seems more obviously useful to me.
[ Parent
| on HN ]
Re:One word in PostgreSQL unlocked a 9x performance improvement
by saltcured on Sunday June 14, 2020 @03:14PM
(#23520466)
The RETURNING semantics produce content of the resulting row after insertion. For the ones that have been skipped, this could be ill-defined. The content is not just the content of the row data that was supplied, but potentially server-generated content from sequences, row-level triggers, etc.
Re:One word in PostgreSQL unlocked a 9x performance improvement
by ivoras on Sunday June 14, 2020 @03:20PM
(#23520513)
There's one HUGE upside for doing it the current way: autogenerated columns.
E.g.
CREATE TABLE t (id SERIAL PRIMARY KEY, x INTEGER UNIQUE);
INSERT INTO t (x) VALUES (42), (43) ON CONFLICT DO NOTHING RETURNING *;
This does EXACTLY the most useful thing if one of '42' or '43' conflicts.