digoal
2024-04-07
PostgreSQL , PolarDB , DuckDB , MERGE , SPLIT , partition
PostgreSQL 17 preview - Implement ALTER TABLE ... MERGE|SPLIT PARTITION
... command
130 ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO
131 (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'),
132 PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'),
133 PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01'));
427 ALTER TABLE salesmans MERGE PARTITIONS (salesmans10_20, salesmans20_30, salesmans30_40) INTO salesmans10_40;
Implement ALTER TABLE ... SPLIT PARTITION ... command
author Alexander Korotkov <akorotkov@postgresql.org>
Sat, 6 Apr 2024 21:58:09 +0000 (00:58 +0300)
committer Alexander Korotkov <akorotkov@postgresql.org>
Sat, 6 Apr 2024 22:18:44 +0000 (01:18 +0300)
commit 87c21bb9412c8ba2727dec5ebcd74d44c2232d11
tree 3ce4f8e030b40814f251997793066a6bac115f1f tree
parent 1adf16b8fba45f77056d91573cd7138ed9da4ebf commit | diff
Implement ALTER TABLE ... SPLIT PARTITION ... command
This new DDL command splits a single partition into several parititions.
Just like ALTER TABLE ... MERGE PARTITIONS ... command, new patitions are
created using createPartitionTable() function with parent partition as the
template.
This commit comprises quite naive implementation which works in single process
and holds the ACCESS EXCLUSIVE LOCK on the parent table during all the
operations including the tuple routing. This is why this new DDL command
can't be recommended for large partitioned tables under a high load. However,
this implementation come in handy in certain cases even as is.
Also, it could be used as a foundation for future implementations with lesser
locking and possibly parallel.
Discussion: https://postgr.es/m/c73a1746-0cd0-6bdd-6b23-3ae0b7c0c582%40postgrespro.ru
Author: Dmitry Koval
Reviewed-by: Matthias van de Meent, Laurenz Albe, Zhihong Yu, Justin Pryzby
Reviewed-by: Alvaro Herrera, Robert Haas, Stephane Tachoires