Missed in PostgreSQL 19 : Add support for INSERT … ON CONFLICT DO SELECT.
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
PostgreSQL 19 adds INSERT ... ON CONFLICT DO SELECT, committed by Dean Rasheed in February 2026. It returns the existing row on a conflict, so "get or create" works in one statement without the dead row, WAL and update triggers of the DO UPDATE workaround. It requires RETURNING and accepts FOR UPDATE/SHARE and a WHERE filter. depesz's examples show the command tag counts returned rows, not inserted ones, which can mislead apps. The old/new values in RETURNING (from version 18) identify inserted rows. The commit details were not independently verified.