postgres update after select
Why not use the RETURNING clause and process both things in one single statement: UPDATE jobs SET status=”RUNNING” WHERE status=”PENDING” RETURNING * That way you will get all rows that were changed by the UPDATE with a single atomic operation.