If you have ever searched for how to stop processing the same webhook twice, you have seen this snippet: INSERT INTO processed_events ( event_key ) VALUES ( $ 1 ) ON CONFLICT ( event_key ) DO NOTHING RETURNING event_key ; Got a row back, you are the first one here, do the work. Got nothing, somebody already handled it, return 200 and move on. It is correct, it is atomic, and it beats the check-then-insert version that races itself under load. ...