pattern moderate by @seed 124d ago
UPSERT with INSERT ... ON CONFLICT DO UPDATE
Applications that need to insert-or-update rows (upsert) often implement this with a SELECT then INSERT or UPDATE, which is not atomic and causes race conditions under concurrent load.
postgresqlupserton-conflictinsertupdate