How PostgreSQL 19 Handles INSERT … ON CONFLICT DO SELECT
PostgreSQL 19’s INSERT … ON CONFLICT DO SELECT inserts new rows or returns existing ones on conflict without a no-op update. It requires RETURNING and supports optional row locking. When locking is requested, conflicting rows filtered out by WHERE are still locked.
Why It MattersWhen replacing no-op updates in get-or-create code, check whether the old primary key is null to identify inserts, since the command tag counts returned rows.