Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciSo1-00043h-Rf for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2017 21:26:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ciSo1-0005Zu-ED for pgsql-hackers@arkaria.postgresql.org; Mon, 27 Feb 2017 21:26:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ciSmV-0002s4-U3 for pgsql-hackers@postgresql.org; Mon, 27 Feb 2017 21:24:31 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ciSmS-0001lR-Gn for pgsql-hackers@postgresql.org; Mon, 27 Feb 2017 21:24:31 +0000 Received: by mail-wm0-x229.google.com with SMTP id u199so29228762wmd.1 for ; Mon, 27 Feb 2017 13:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=X+F6SB2IP/o5GC1eqPpuJWiKa9Y5lXfSJY6U22IKOvQ=; b=hj9TEqBgLQQerJS5dirRsPlLBeS4E1WJNfCuF8i0FlisRC3dG63kOn8HKfmK6qFC4v kxo35t/r+SWxwc7G04MQHAzV/Mhqtf1Z3Y+0htV67KxJM+BOypqY8TG9TubGUV31Wn+z AARsZBJWW5ATSgUHSzFRGc0oGAyvw+uMNJ8cWAPSln4SWzw4Oucgn1ETP5Bf0vOgVaZM CgELN0v/7bkzbku3KAmU6VfNgpHIqDmAhfe64tDZEpw1LuVkIA+WA79HrxvIYw39+QoJ pK4hUm2eutebMUnpZiGlPo1iqQ74Ij34SZ5qlix6LBiV3NXjzzkEDd88RERxKU2ZijWZ 3ruQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=X+F6SB2IP/o5GC1eqPpuJWiKa9Y5lXfSJY6U22IKOvQ=; b=eZrMnI6cIZs719es4Q0DSsuqCZXNjf0OF6Jq0gu4icF4OFI+xv+9CS0D8tqTtZTtIf 07QGtfSU/YB6w4T/zT7qpqwyiGRxcKmv5LJWR8leoMyINSoswkoe9oHl0g9I/yKNb/Mg E4R7cmWRvUmr9Wg5lGgVYBEZKJWrLeiPEDl0Mclxx2IkJ7lPu65MqLUxRDnidJQ/M6+v jQVRT2xl9tPlyIp4NMUYEAkQtIos+THElMZQFdYayHZC2l8aO6Jdvn83xXoRItdV5o7x YspNV6QNWAWiuDGcDTSCh6XSDG85Y1PHGq6QrrgINaspAFkY4MJgF1Y6RqjrtEEc5XsS 3+RA== X-Gm-Message-State: AMke39nhXu8xd6EL5FuWwvHojwR/ULFdkxEhMIkP6KRZAACMoXlPLUbxbD19+JpKD4dxr5mvk5tCBUEYJ/z7xaZCUco6LWa2koyCgjGHq79Fqm387dBTwpzrKDOjTM0V2QbGdfuOm5rt2U8+tMM1V4oY3FM/fvmbWrZMItQavu4pg9YhiCP6WazLytmPtv002226xB5TbmjC X-Received: by 10.28.54.139 with SMTP id y11mr13783391wmh.112.1488230666827; Mon, 27 Feb 2017 13:24:26 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id u189sm15765765wmu.1.2017.02.27.13.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Feb 2017 13:24:25 -0800 (PST) Subject: Re: Documentation improvements for partitioning To: Amit Langote , Robert Haas , Simon Riggs References: <4ee94808-968a-57d7-c12a-a18f08138a2f@lab.ntt.co.jp> <20170220203320.GB2672@momjian.us> <70d3b45d-f76a-904b-7bd9-8355604d2643@lab.ntt.co.jp> Cc: Bruce Momjian , Corey Huinker , Pg Hackers From: Petr Jelinek Message-ID: Date: Mon, 27 Feb 2017 22:24:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <70d3b45d-f76a-904b-7bd9-8355604d2643@lab.ntt.co.jp> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 27/02/17 07:59, Amit Langote wrote: > On 2017/02/27 3:18, Petr Jelinek wrote: >> On 24/02/17 07:15, Robert Haas wrote: >>> On Fri, Feb 24, 2017 at 9:53 AM, Simon Riggs wrote: >>>> The good news is that logical replication DOES work with partitioning, >>>> but only for a Publication with PUBLISH INSERT, pushing from a normal >>>> table to a partitioned one. Which is useful enough for first release. >>>> >>>> The work on having UPDATE work between partitions can be used to make >>>> updates and deletes work in logical replication. That might yet be >>>> made to work in this release, and I think we should look into it, but >>>> I think it can be left til next release if we try. >>> >>> Are you speaking of the case where you want to replicate from an >>> unpartitioned table to a partitioned table? I would imagine that if >>> you are replicating between two identical partitioning hierarchies, it >>> would just work. (If not, that's probably a bug, though I don't know >>> whose bug.) >>> >> >> Yes same hierarchies will work but mainly because one has to add >> partitions themselves to publication currently. I guess that's the >> limitation we might have to live with in 10 as adding the whole >> partitioned table should probably work for different hierarchies when we >> enable it and I am not quite sure that's doable before start of the CF >> at this point. > > If and when we add support to add partitioned tables to publications, I > think it will work by recursing to include the partitions to the same > publication (I see that OpenTableList() in publicationcmds.c calls > find_all_inheritors if recursion is requested by not specifying ONLY). > When a subscription replicates from this publication, it's going to match > changes for individual leaf partitions, not the root parent table. IOW, > none of the changes applied to a partitioned table are replicated as > changes to the table itself. So, it seems that adding a partitioned table > to a publication or subscription would simply be a *shorthand* for adding > all the (leaf) partitions that will actually emit and receive changes. This was my first thought as well. However we need to also take into account the use-case with different partitioning topology on publisher and subscriber (at least in a sense that the initial design will not paint us in the corner). Now I see two ways of achieving this. a) Either going with more or less what you wrote above and in the future have some smarts where we can specify that it should replicate with different name. We'll eventually want to be able to replicate table to differently named table anyway so it's not stretch by any means to do that. b) Or just replicate changes to leaf partitions as changes to partitioned table. That's also not that hard to do, we just need fast lookup of partitioned table from leaf table. I guess a) looks simpler given that we eventually need the rename anyway, but I'd like opinions of other people as well. > I'm not sure but should adding/removing partitions after the fact cause > their addition/removal from the publication (& subscription)? Maybe we'll > discuss these issues later. That's something I've been also wondering as there is many corner cases here. For example if table is in some publication and then is added as partition to partitioned table what should happen? What should happen when the partitioned table is then removed from same publication to which partition was added explicitly? Should we allow different publication configuration for different partitions within same partitioned table, etc? This somewhat brings bigger question about where we want to go in general with partitioning. And that is, should partition be a separate entity that is on the same level of table, or should it be part of the partitioned table without it's own "identity". -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers