Allowing TRUNCATE of FK target when session_replication_role=replica - Mailing list pgsql-hackers

From Hannu Krosing
Subject Allowing TRUNCATE of FK target when session_replication_role=replica
Date
Msg-id CAMT0RQQfF3k_Ri7-zvQ2X=mt=d0Qx5qGJojk=1P8oaL6yU=+1w@mail.gmail.com
Whole thread Raw
Responses Re: Allowing TRUNCATE of FK target when session_replication_role=replica
List pgsql-hackers
Hi

Currently we do not allow TRUNCATE of a table when any Foreign Keys
point to that table.

At the same time we do allow one to delete all rows when
session_replication_role=replica

This causes all kinds of pain when trying to copy in large amounts of
data, especially at the start of logical replication set-up, as many
optimisations to COPY require the table to be TRUNCATEd .

The main two are ability to FREEZE while copying and the skipping of
WAL generation in case of wal_level=minimal, both of which can achieve
significant benefits when data amounts are large.

Is there any reason to not allow TRUNCATE when
session_replication_role=replica ?

Unless there are any serious objections, I will send a patch to also
allow TRUNCATE in this case.


Best Regards
Hannu



pgsql-hackers by date:

Previous
From: torikoshia
Date:
Subject: Re: Add new option 'all' to pg_stat_reset_shared()
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: A recent message added to pg_upgade