Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iY6SK-00013o-AD for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Nov 2019 10:46:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iY6SI-0004Ay-Tn for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Nov 2019 10:46:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iY6SI-0004Aq-HU for pgsql-hackers@lists.postgresql.org; Fri, 22 Nov 2019 10:46:26 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iY6S9-0005Iz-M6 for pgsql-hackers@postgresql.org; Fri, 22 Nov 2019 10:46:25 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 28CE323591; Fri, 22 Nov 2019 05:46:16 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Fri, 22 Nov 2019 05:46:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=A3wgJ2OsVUybSpTDE2KKn1c6niC6Nyj+92Ycv3fAV Jw=; b=SvDJLBQycJLR9UqUalnjkzyywyCX6gzpdEcgUoPk4z4aZur0NWZoBbtfK LCoILYFN9hHNz07YPXhIj/VAWcMxoaxL4WFnQTfeFco5R9DPSa1Ow5Plzz/M6ZZj Pvo8hrf9NeIhAwYqTAyPEj5S8rbiBFA3wJuu+noWgOKOZsoBgVOhN7se4LYrB9Ii aiHAmRCBqWbbuHBiDuEUiQ+Fvpkjy/VtLruAujEeAALMmdyXPxc5mlYGZJLDyy6D +097Y1gNpVOPgM6RlE1sT3XJSsVnMM3IJhWBZlr6lxCX18E3mrX/TOet1L63wA0/ 1c5Vk1K43iqFC+6UQpkqB8p6TSnzA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudehgedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhohfkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnug hquhgrughrrghnthdrtghomheqnecuffhomhgrihhnpedvnhguqhhurggurhgrnhhtrdgt ohhmnecukfhppeelfedrvdegvddrudegjedrjeelnecurfgrrhgrmhepmhgrihhlfhhroh hmpehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnughquhgrughrrghnthdrtghomhen ucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from april.pezone.net (p5df2934f.dip0.t-ipconnect.de [93.242.147.79]) by mail.messagingengine.com (Postfix) with ESMTPA id 3AB693060057; Fri, 22 Nov 2019 05:46:15 -0500 (EST) Subject: Re: adding partitioned tables to publications To: Amit Langote References: <037d3133-1689-108c-360d-b782e3209cfb@2ndquadrant.com> Cc: Rafia Sabih , PostgreSQL-development From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <7a23e60b-ffe8-bce1-5c44-db48d3bc163e@2ndquadrant.com> Date: Fri, 22 Nov 2019 11:46:14 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-11-22 07:28, Amit Langote wrote: > Hmm, I thought it would be more desirable to not expose a published > partitioned table's leaf partitions to a subscriber, because it allows > the target table to be defined more flexibly. There are multiple different variants that we probably eventually want to support. But I think there is value in exposing the partition structure to the subscriber. Most notably, it allows the subscriber to run the initial table sync per partition rather than in one big chunk -- which ultimately reflects one of the reasons partitioning exists. The other way, exposing only the partitioned table, is also useful, especially if you want to partition differently on the subscriber. But without the ability to target a partitioned table on the subscriber, this would right now only allow you to replicate a partitioned table into a non-partitioned table. Which is valid but probably not often useful. >> What happens when you add a leaf table directly to a publication? Is it >> replicated under its own identity or under its ancestor partitioned >> table? (What if both the leaf table and a partitioned table are >> publication members?) > > If both a leaf partition and an ancestor belong to the same > publication, then leaf partition changes are replicated using the > ancestor's schema. For a leaf partition to be replicated using its > own schema it must be published via a separate publication that > doesn't contain the ancestor. At least that's what the current patch > does. Hmm, that seems confusing. This would mean that if you add a partitioned table to a publication that already contains leaf tables, the publication behavior of the leaf tables would change. So again, I think this alternative behavior of publishing partitions under the name of their root table should be an explicit option on a publication, and then it should be ensured somehow that individual partitions are not added to the publication in confusing ways. So, it's up to you which aspect of this you want to tackle, but I thought your original goal of being able to add partitioned tables to publications and have that implicitly expand to all member partitions on the publication side seemed quite useful, self-contained, and uncontroversial. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services