Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMXWb-0002lr-6x for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 13:47:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMXW4-0003gJ-8Y for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 13:46:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMXW4-0003gC-1R for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2020 13:46:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jMXVx-0004rh-IZ for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2020 13:46:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 039Dkccl027753; Thu, 9 Apr 2020 09:46:38 -0400 From: Tom Lane To: Amit Langote cc: Alvaro Herrera , Justin Pryzby , PostgreSQL Hackers Subject: Re: DETACH PARTITION and FOR EACH ROW triggers on partitioned tables In-reply-to: References: <20200408180110.GA17093@alvherre.pgsql> <5954.1586369358@sss.pgh.pa.us> Comments: In-reply-to Amit Langote message dated "Thu, 09 Apr 2020 22:04:02 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27751.1586439998.1@sss.pgh.pa.us> Date: Thu, 09 Apr 2020 09:46:38 -0400 Message-ID: <27752.1586439998@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Amit Langote writes: > On Thu, Apr 9, 2020 at 3:09 AM Tom Lane wrote: >> My point is that so long as you only allow the case of exactly one parent, >> you can just delete the child trigger, because it must belong to that >> parent. As soon as there's any flexibility, you are going to end up >> reinventing all the stuff we had to invent to manage >> maybe-or-maybe-not-inherited columns. So I think the "detach" idea >> is the first step on that road, and I counsel not taking that step. > As mentioned upthread, we have behavior #1 for indexes (attach > existing / detach & keep), without any of the *islocal, *inhcount > infrastructure. It is a bit complex, because we need logic to check > the equivalence of an existing index on the partition being attached, > so implementing the same behavior for trigger is going to have to be > almost as complex. Considering that #2 will be much simpler to > implement, but would be asymmetric with everything else. I think there is justification for jumping through some hoops for indexes, because they can be extremely expensive to recreate. The same argument doesn't hold even a little bit for child triggers, though. Also it can be expected that an index will still behave sensibly after its table is standalone, whereas that's far from obvious for a trigger that was meant to work on partition member tables. regards, tom lane