Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcgHX-001Qss-If for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 06:40:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rcgHV-0037dq-T0 for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Feb 2024 06:40:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcgHV-0037di-Jq for pgsql-hackers@lists.postgresql.org; Wed, 21 Feb 2024 06:40:38 +0000 Received: from wfout3-smtp.messagingengine.com ([64.147.123.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcgHT-0007ur-0w for pgsql-hackers@postgresql.org; Wed, 21 Feb 2024 06:40:37 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 3E5341C00090; Wed, 21 Feb 2024 01:40:31 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 21 Feb 2024 01:40:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1708497630; x=1708584030; bh=cJgji+/SHi D3YxC7TV9a2Lu7JTM6swOguz7haXowIY4=; b=W7kLFP/evXuR/idJJyGyficV4m 7qYoL0OCMdwSl3VTBfD1L8a5wBF3ruRwyE3j5A2Ju+cSffMw9Zll2yzZ5LzaoF8Z nW3NVvJUBXzh9X+/d+ifedtUtMGlctO3w9f1w3fjSoxxQytgUQbh+qqouf0STIp3 CVrkBc3+o2YX8Ie8RG8mpI0GDljmbN+bNc/XjUThYg6kPrhf3E2E/OUSGM0QVQzy 25uD6113tlqSSmZCkSnogzBea62baySvAnAmxHVc0MJodkEQHXU6XyGHwG5NrVP8 4moiRR51CCRqFahkhPYsIPv3GLkczy1bL+NizGd+sATl2t5CK12f7RqVu78g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708497630; x=1708584030; bh=cJgji+/SHiD3YxC7TV9a2Lu7JTM6 swOguz7haXowIY4=; b=qQzQ965fFZ7+ffkn2kC03c6vhJ0iul2kM2ZmFEsJwRVQ 3gpeew6hMaXOeNqwTGRUL25so1ZjjUNPAKLjhYzjIpp+HPNYDfAkX3rH8D/doURe VONCc8Rg/tnlAjnsK30s+z9oj5pArLX8kDpvf/gpI9LaVHqk3Ap9DrOoEBIV0Dwf GgHDcS1z/Mayppnp5pxvIdaGNP/n7fZUA7+PBCrRAeJrRaoX0b2qBKY2nSHObqEQ MJ1LajzpmvYzI9R63fEV1Nir2vmvhysBpYPGNXP96tTUBJEKS5zqiaauIX6GjGhU 0uW8Bp6zHqBz8t+MmbrvpHTpZtf2FqfhFOLDGw2AEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedugdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdefhedmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeegffejvefgveduvdejtddvtdei jeehudeuledvudeftdfgfeejvdekveekiedvvdenucffohhmrghinhepphhoshhtghhrvg hsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Feb 2024 01:40:27 -0500 (EST) Date: Wed, 21 Feb 2024 15:40:18 +0900 From: Michael Paquier To: Peter Eisentraut Cc: Justin Pryzby , Soumyadeep Chakraborty , Zhihong Yu , pgsql-hackers@postgresql.org, Ashwin Agrawal , vanjared@vmware.com Subject: Re: ALTER TABLE SET ACCESS METHOD on partitioned tables Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="QG0JSu0iMg4ikH9Y" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --QG0JSu0iMg4ikH9Y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 20, 2024 at 03:47:46PM +0100, Peter Eisentraut wrote: > It would be helpful if this patch could more extensively document in its > commit message what semantic changes it makes. Various options of possib= le > behaviors were discussed in this thread, but it's not clear which behavio= rs > were chosen in this particular patch version. >=20 > The general idea is that you can set an access method on a partitioned > table. That much seems very agreeable. But then what happens with this > setting, how can you override it, how can you change it, what happens when > you change it, what happens with existing partitions and new partitions, > etc. -- and which of these behaviors are new and old. Many things to > specify. The main point in this patch is the following code block in DefineRelation(), that defines the semantics about the AM set for a partitioned table: + else if (RELKIND_HAS_TABLE_AM(relkind) || relkind =3D=3D RELKIND_PARTI= TIONED_TABLE) { + if (stmt->partbound) + { + /* + * For partitions, if no access method is specified, use the A= M of + * the parent table. + */ + Assert(list_length(inheritOids) =3D=3D 1); + accessMethodId =3D get_rel_relam(linitial_oid(inheritOids)); + Assert(OidIsValid(accessMethodId)); + } + else + accessMethodId =3D get_table_am_oid(default_table_access_metho= d, false); } This means that all partitioned tables would have pg_class.relam set, and that relam would never be 0: - The USING clause takes priority over default_table_access_method. - If no USING clause, default_table_access_method is the AM used Any partitions created from this partitioned table would inherit the AM set, ignoring default_table_access_method. =20 Alvaro has made a very good point a couple of days ago at [1] where we should try to make the behavior stick closer to tablespaces, where it could be possible to set relam to 0 for a partitioned table, where a partition would inherit the AM set in the GUC when a USING clause is not defined (if USING specifies the AM, we'd just use it). Existing partitions should not be changed if the AM of their partitioned table changes, so you can think of the AM as a hint for the creation of new partitions. [1]: https://www.postgresql.org/message-id/202402011550.sfszd46247zi@alvher= re.pgsql -- Michael --QG0JSu0iMg4ikH9Y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmXVmtIACgkQnvQgOdby QH032w//eUZup4UpA6jrfm+mIwIPIM8BKuEgn1+LkUZdHumlCGxQJzMyQ2adct1B swvv9rpqNvjy8e3+trvn7CZUibJzAhLB5b4P/aLOB/wY0wQJuckcsaqiELSTHLsh mIWZ+u61Kc3cZGPjlF0/+P93OzAiqgKsGSDiAP0JltJ4GED48Y3dT8dpdaD9G9yo b5mNkYvjcmB+dx9m/32R6peJu6XyI4qgqx517sgu70vyhNHJBmgQNSmK245DtuEg 3ZnDXaQ8G2WBZODkg054Wfp+uE0J1BRGoMqJzUEyRWuIqLxm+sF49MZjHqMu9SgC /SpmoMsWL6JTEMWpbDGDNBBOXI6QafR8uTCn/CV9+KJrBjt9s9FXd4I9FxWiILx1 IogVdHrTq9ARD9+zHJ7hFORQJxKeWAO8G7/n7aoFNwzgfbkWXL1NOyUATO+oWWdY YvYNNGUAHlcGVkEFFJfDrlmgQDpi0fVP77S8vqPmL1yNAb98CdpoBa6TftOn6u7k O55Jz09X0izg+bEJvNDOey6AwNKd7vhsd/QPeqxwGFf70Zu+mXhTQyYou5Muerq3 2eCrpJHp/EFxyZ3ynCjRtmvko8sFnvaBl6OJYkPIo1Ubj5F91rbEDeLeodefiqSE sOf4faGmAvFA00/v0+YoOUvyWv2DbvGV/mbBy0CJivHTwx4H5B0= =IUdE -----END PGP SIGNATURE----- --QG0JSu0iMg4ikH9Y--