pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeremy Schneider <schnjere@amazon.com>
To: Simon Riggs <simon@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: pgsql-general@lists.postgresql.org
Subject: Logical decoding of TRUNCATE vs DELETE
Date: Thu, 25 Jan 2018 12:03:36 -0800
Message-ID: <8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com> (raw)
In-Reply-To: <CANP8+jKe2MxtH4Ck70tUY6wP=OnkkkXRt8Xkx1u6+50HM2wHvQ@mail.gmail.com>
References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it>
	<20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de>
	<CANP8+jKe2MxtH4Ck70tUY6wP=OnkkkXRt8Xkx1u6+50HM2wHvQ@mail.gmail.com>

Seeing that patch development is coming along at a nice pace, it seems a
good time to discuss this question.

On 1/4/18 03:24, Simon Riggs wrote:
> At present the patch treats TRUNCATE as if it were a DELETE
> 
> ...
> 
> CREATE PUBLICATION insert_only FOR TABLE mydata;
> will now publish TRUNCATEs, although they were ignored in PG10
> so PG10 publications will act differently
> 
> I had regarded it as a missing piece, but some may view that is a
> behaviour change in PG11

My understanding of this design is that there's no possible way to make
a PG11 database behave like a PG10 database did. For example, if someone
has a data warehouse with a single table that's subscribed to publishers
on multiple source databases, they would certainly not want truncate SQL
replicated. If they just upgrade their database without reading all the
release notes (not that anyone would ever do that), they might get a
surprise data loss in the warehouse. Of course I wouldn't suggest using
truncate on their sources - but people may still do it.

> Alternatively, we could also use WITH (publish = 'truncate') as a
> separate decision.
>
> That is an easy change if we wish it.

Of course the user could simply not _allow_ truncate commands on the
source tables via permissions and/or triggers; that seems a little more
"correct" to me from a DB design perspective. But I still like Simon's
idea here of using WITH as a separate decision. I'm sure that there will
be users somewhere who build systems based on our PG10 design - this at
least doesn't completely leave them out to dry, and I don't see any big
downsides to having the separate decision for truncate.

In addition, this seems a little more consistent. In other places that
comes to mind (e.g. triggers and privileges), truncate is treated
distinctly from delete. Makes sense to me to continue that convention.

-Jeremy

-- 
Jeremy Schneider
Database Engineer
Amazon Web Services
+1 312-725-9249 (m)
schnjere@amazon.com




Message-ID: <8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com>
Permalink:  ../8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com/
Also on:    postgresql.org/message-id/8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: schnjere@amazon.com, simon@2ndquadrant.com, andres@anarazel.de, marco.nenciarini@2ndquadrant.it, pgsql-hackers@postgresql.org
  Subject: Re: Logical decoding of TRUNCATE vs DELETE
  In-Reply-To: <8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com>
  References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de> <CANP8+jKe2MxtH4Ck70tUY6wP=OnkkkXRt8Xkx1u6+50HM2wHvQ@mail.gmail.com> <8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com>

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

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