The problem is way worse if you update rows, if you stick with insert and delete you can get quite far.
In Postgres, an UPDATE is effectively an INSERT + DELETE [0].
0: https://www.cybertec-postgresql.com/en/is-update-the-same-as...
0: https://www.cybertec-postgresql.com/en/is-update-the-same-as...