From 374c7a2290429eac3217b0c7b0b485db9c2bcc72 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Mon, 25 Mar 2024 16:30:36 +0100 Subject: Allow specifying an access method for partitioned tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's now possible to specify a table access method via CREATE TABLE ... USING for a partitioned table, as well change it with ALTER TABLE ... SET ACCESS METHOD. Specifying an AM for a partitioned table lets the value be used for all future partitions created under it, closely mirroring the behavior of the TABLESPACE option for partitioned tables. Existing partitions are not modified. For a partitioned table with no AM specified, any new partitions are created with the default_table_access_method. Also add ALTER TABLE ... SET ACCESS METHOD DEFAULT, which reverts to the original state of using the default for new partitions. The relcache of partitioned tables is not changed: rd_tableam is not set, even if a partitioned table has a relam set. Author: Justin Pryzby Author: Soumyadeep Chakraborty Author: Michaƫl Paquier Reviewed-by: The authors themselves Discussion: https://postgr.es/m/CAE-ML+9zM4wJCGCBGv01k96qQ3gFv4WFcFy=zqPHKeaEFwwv6A@mail.gmail.com Discussion: https://postgr.es/m/20210308010707.GA29832%40telsasoft.com --- doc/src/sgml/catalogs.sgml | 10 +++++++--- doc/src/sgml/ref/alter_table.sgml | 18 ++++++++++++++---- doc/src/sgml/ref/create_table.sgml | 4 ++++ 3 files changed, 25 insertions(+), 7 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 29817fb33c6..096ddab481c 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1988,9 +1988,13 @@ SCRAM-SHA-256$<iteration count>:&l (references pg_am.oid) - If this is a table or an index, the access method used (heap, - B-tree, hash, etc.); otherwise zero (zero occurs for sequences, - as well as relations without storage, such as views) + The access method used to access this table or index. + Not meaningful if the relation is a sequence or + has no on-disk file, + except for partitioned tables, where, if set, it takes + precedence over default_table_access_method + when determining the access method to use for partitions created + when one is not specified in the creation command. diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 96e3d776051..6cdcd779ef8 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -732,10 +732,20 @@ WITH ( MODULUS numeric_literal, REM SET ACCESS METHOD - This form changes the access method of the table by rewriting it. See - for more information. Writing - DEFAULT changes the access method of the table - to . + This form changes the access method of the table by rewriting it + using the indicated access method; specifying + DEFAULT selects the access method set as the + configuration + parameter. + See for more information. + + + When applied to a partitioned table, there is no data to rewrite, + but partitions created afterwards will default to the given access + method unless overridden by a USING clause. + Specifying DEFAULT removes a previous value, + causing future partitions to default to + default_table_access_method. diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 118c7053e60..dfb7822985e 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1365,6 +1365,10 @@ WITH ( MODULUS numeric_literal, REM method is chosen for the new table. See for more information. + + When creating a partition, the table access method is the access method + of its partitioned table, if set. + -- cgit v1.2.3