The problem is way worse if you update rows, if you stick with insert and delete you can get quite far.
sgarland2 days ago | | | parent | | on: 47734514
In Postgres, an UPDATE is effectively an INSERT + DELETE [0].

0: https://www.cybertec-postgresql.com/en/is-update-the-same-as...