Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eenkW-00035V-DA for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2018 20:03:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eenkV-0006we-CC for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2018 20:03:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eenkV-0006wL-04 for pgsql-hackers@lists.postgresql.org; Thu, 25 Jan 2018 20:03:51 +0000 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eenkS-0002QP-9N for pgsql-hackers@postgresql.org; Thu, 25 Jan 2018 20:03:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1516910628; x=1548446628; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=q/1djXqhB/6Uwus+SYDgdw5R55Eh1b3+12r1uO0iG70=; b=Xg2vqrihzogSNnx1RqAfCE3XBVP+RXruhuq4wVzZdyFMMcAI500iqaVt mI5cOFH9LqwmsK3VrYa96TDOJ20Vx84E5Cy0fxEG9/FL4fWiqClXKxD2x bfRKLrBvFT45Ajdio/JAkPCx6BcfV+6iaTScfx/CyZkZaBftiCzjYW/Ll 8=; X-IronPort-AV: E=Sophos;i="5.46,413,1511827200"; d="scan'208";a="589976787" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Jan 2018 20:03:40 +0000 Received: from EX13MTAUWA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1a-715bee71.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w0PK3a1x085301 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 25 Jan 2018 20:03:37 GMT Received: from EX13D18UWA002.ant.amazon.com (10.43.160.199) by EX13MTAUWA001.ant.amazon.com (10.43.160.58) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 25 Jan 2018 20:03:37 +0000 Received: from 186590ce269b.ant.amazon.com (10.43.162.107) by EX13D18UWA002.ant.amazon.com (10.43.160.199) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Thu, 25 Jan 2018 20:03:37 +0000 Subject: Logical decoding of TRUNCATE vs DELETE To: Simon Riggs , Andres Freund CC: Marco Nenciarini , PostgreSQL-development , References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de> From: Jeremy Schneider Message-ID: <8b154058-18bf-ce42-d221-e5eb167e843d@amazon.com> Date: Thu, 25 Jan 2018 12:03:36 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.43.162.107] X-ClientProxiedBy: EX13D20UWC004.ant.amazon.com (10.43.162.41) To EX13D18UWA002.ant.amazon.com (10.43.160.199) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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