pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command 2+ messages / 1 participants [nested] [flat]
* pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command @ 2024-04-06 22:19 Alexander Korotkov <akorotkov@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Alexander Korotkov @ 2024-04-06 22:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/87c21bb9412c8ba2727dec5ebcd74d44c2232d11 Modified Files -------------- doc/src/sgml/ddl.sgml | 19 + doc/src/sgml/ref/alter_table.sgml | 65 +- src/backend/commands/tablecmds.c | 411 ++++++ src/backend/parser/gram.y | 38 +- src/backend/parser/parse_utilcmd.c | 62 +- src/backend/partitioning/partbounds.c | 657 +++++++++ src/backend/utils/adt/ruleutils.c | 18 + src/include/nodes/parsenodes.h | 1 + src/include/parser/kwlist.h | 1 + src/include/partitioning/partbounds.h | 5 + src/include/utils/ruleutils.h | 2 + src/test/isolation/expected/partition-split.out | 190 +++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/partition-split.spec | 54 + .../modules/test_ddl_deparse/test_ddl_deparse.c | 3 + src/test/regress/expected/partition_split.out | 1417 ++++++++++++++++++++ src/test/regress/parallel_schedule | 2 +- src/test/regress/sql/partition_split.sql | 833 ++++++++++++ src/tools/pgindent/typedefs.list | 1 + 19 files changed, 3766 insertions(+), 14 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command @ 2025-12-14 11:30 Alexander Korotkov <akorotkov@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Alexander Korotkov @ 2025-12-14 11:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Implement ALTER TABLE ... SPLIT PARTITION ... command This new DDL command splits a single partition into several partitions. Just like the ALTER TABLE ... MERGE PARTITIONS ... command, new partitions are created using the createPartitionTable() function with the parent partition as the template. This commit comprises a quite naive implementation which works in a single process and holds the ACCESS EXCLUSIVE LOCK on the parent table during all the operations, including the tuple routing. This is why the new DDL command can't be recommended for large, partitioned tables under high load. However, this implementation comes in handy in certain cases, even as it is. Also, it could serve as a foundation for future implementations with less locking and possibly parallelism. Discussion: https://postgr.es/m/c73a1746-0cd0-6bdd-6b23-3ae0b7c0c582%40postgrespro.ru Author: Dmitry Koval <d.koval@postgrespro.ru> Co-authored-by: Alexander Korotkov <aekorotkov@gmail.com> Co-authored-by: Tender Wang <tndrwang@gmail.com> Co-authored-by: Richard Guo <guofenglinux@gmail.com> Co-authored-by: Dagfinn Ilmari Mannsaker <ilmari@ilmari.org> Co-authored-by: Fujii Masao <masao.fujii@gmail.com> Co-authored-by: Jian He <jian.universality@gmail.com> Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com> Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at> Reviewed-by: Zhihong Yu <zyu@yugabyte.com> Reviewed-by: Justin Pryzby <pryzby@telsasoft.com> Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Reviewed-by: Robert Haas <rhaas@postgresql.org> Reviewed-by: Stephane Tachoires <stephane.tachoires@gmail.com> Reviewed-by: Jian He <jian.universality@gmail.com> Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> Reviewed-by: Pavel Borisov <pashkin.elfe@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Alexander Lakhin <exclusion@gmail.com> Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Reviewed-by: Daniel Gustafsson <dgustafsson@postgresql.org> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Noah Misch <noah@leadboat.com> Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4b3d173629f4cd7ab6cd700d1053af5d5c7c9e37 Modified Files -------------- doc/src/sgml/ddl.sgml | 19 + doc/src/sgml/ref/alter_table.sgml | 118 +- src/backend/commands/tablecmds.c | 432 ++++++ src/backend/parser/gram.y | 38 +- src/backend/parser/parse_utilcmd.c | 197 ++- src/backend/partitioning/partbounds.c | 737 ++++++++- src/bin/psql/tab-complete.in.c | 10 +- src/include/nodes/parsenodes.h | 34 +- src/include/parser/kwlist.h | 1 + src/include/partitioning/partbounds.h | 4 + src/test/isolation/expected/partition-split.out | 230 +++ src/test/isolation/isolation_schedule | 1 + src/test/isolation/specs/partition-split.spec | 62 + .../test_ddl_deparse/expected/alter_table.out | 5 + .../modules/test_ddl_deparse/sql/alter_table.sql | 4 + .../modules/test_ddl_deparse/test_ddl_deparse.c | 3 + src/test/regress/expected/partition_split.out | 1592 ++++++++++++++++++++ src/test/regress/parallel_schedule | 2 +- src/test/regress/sql/partition_split.sql | 1134 ++++++++++++++ src/tools/pgindent/typedefs.list | 2 + 20 files changed, 4585 insertions(+), 40 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-12-14 11:30 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-04-06 22:19 pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command Alexander Korotkov <akorotkov@postgresql.org> 2025-12-14 11:30 pgsql: Implement ALTER TABLE ... SPLIT PARTITION ... command Alexander Korotkov <akorotkov@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox