public inbox for [email protected]  
help / color / mirror / Atom feed
From: Hannu Krosing <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: Allowing TRUNCATE of FK target when session_replication_role=replica
Date: Tue, 31 Oct 2023 09:09:24 +0100
Message-ID: <CAMT0RQQfF3k_Ri7-zvQ2X=mt=d0Qx5qGJojk=1P8oaL6yU=+1w@mail.gmail.com> (raw)

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






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Allowing TRUNCATE of FK target when session_replication_role=replica
  In-Reply-To: <CAMT0RQQfF3k_Ri7-zvQ2X=mt=d0Qx5qGJojk=1P8oaL6yU=+1w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox