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 1lO3Q1-00042S-VY for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Mar 2021 19:07: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 1lO3Q0-0006Wv-U0 for pgsql-hackers@arkaria.postgresql.org; Sun, 21 Mar 2021 19:07:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lO3Q0-0006Wm-N1 for pgsql-hackers@lists.postgresql.org; Sun, 21 Mar 2021 19:07:20 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lO3Py-0008AR-9O for pgsql-hackers@lists.postgresql.org; Sun, 21 Mar 2021 19:07:19 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 647BA10A2; Sun, 21 Mar 2021 15:07:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 21 Mar 2021 15:07:16 -0400 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:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=VRmLl9goVyTELB26xuHgepjcRqle9ouIw+68MZGTT1k=; b=kZKcPgas 2kaio15mUnKwfP3VobzzWZQlqNDfBbIgLjFbp62R8Fm5+B58gIX4Z062sOm1IYer nhSQinOdwT6RIUa9XG/7oPELC8yjqzyFnuT3dogzXFwFmCmSK51mzE63M2vjIxuC 6dHu0ggXS7zoi5EWaYBamHFNe6AV2JFKn6ZQvR6dShafKc7dA/2j2rg9ctJbD0JT aZIygSwxQuqbes+qgCQKnU86QHhQZP0uFwWwU4RyDKCvevEd+OYkNxB3NysqnXV/ J2YLQuptYcS5NsQRBvw5R9wKRBUWnG/+Vxy0tjMjc0QTT2MttQx5VFsrKpKsM5Sn Vxbpl09J67P+RQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudegvddguddvudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjggfsehtkeertddtredunecuhfhrohhmpeetlhhv rghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hgqeenucggtffrrghtthgvrhhnpeevjeejkeejjeeiveeuuddvfeffiefhfffgleehgfeu geejheduvdefkeeihffftdenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorh hg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 8F566240274; Sun, 21 Mar 2021 15:07:15 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 405F92A0FD5; Sun, 21 Mar 2021 16:07:12 -0300 (-03) Date: Sun, 21 Mar 2021 16:07:12 -0300 From: Alvaro Herrera To: Justin Pryzby Cc: Amit Langote , pgsql-hackers@lists.postgresql.org Subject: Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY Message-ID: <20210321190712.GA8502@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210321182903.GD11765@telsasoft.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Mar-21, Justin Pryzby wrote: > On Sun, Mar 21, 2021 at 03:22:00PM -0300, Alvaro Herrera wrote: > > > So if we do that on DETACH, what would happen on ATTACH? > > Do you mean what happens to the constraint that was already there ? > Nothing, since it's not ours to mess with. Checking ImpliedBy() rather than > equal() doesn't change that. No, I meant what happens regarding checking existing values in the table: is the table scanned even if the partition constraint is implied by existing table constraints? > I proposed this a few years ago for DETACH (without concurrently), specifically > to avoid the partition scans. > https://www.postgresql.org/message-id/20180601221428.GU5164@telsasoft.com > |The docs say: if detaching/re-attach a partition, should first ADD CHECK to > |avoid a slow ATTACH operation. Perhaps DETACHing a partition could > |implicitly CREATE a constraint which is usable when reATTACHing? Well, I agree with you that we should add such a constraint. -- Álvaro Herrera Valdivia, Chile "The problem with the future is that it keeps turning into the present" (Hobbes)