My use case is the following:

I have big table `users` (~200 millions rows) of users with `user_id` as the primary key. `users` is referenced by several other tables using foreign key with `ON DELETE CASCADE`.

Every day I have to replace the whole content of `users` using a lot of csv files. (Please don't ask why I have to do that, I just have to...)

My idea was to set the primary key and all foreign keys as DEFERRED, then, in the same transaction, DELETE the whole table and copying all the csvs using the COPY command. The expected result was that all check and index calculation would happen at the end of the transaction.
But actually the insert process is super slow (4hours, against 10min if I insert and the put the primary key) AND no foreign key can refer to a deferrable primary.
I can't remove the primary key during the insertion because of the foreign keys. I don't want get rid of the foreign key either because I would have to simulate the behavior of `ON DELETE CASCADE` manually.

**So basically I am looking for a way to tell postgres to not care about primary key index or foreign key check until the very end of the transaction.**

PS1: I made up the users table, I am actually working with very different kind of data but it's not really relevant to the problem.

PS2: As a rough estimation I would say that every day, on my 200+ millions records, I have 10 records removed, 1million updated and 1million added.