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.96) (envelope-from ) id 1vQ9Nd-00CiLp-0m for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Dec 2025 19:16:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQ9Nb-0047PH-2R for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Dec 2025 19:16:12 +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.96) (envelope-from ) id 1vQ9Nb-0047P9-1G for pgsql-hackers@lists.postgresql.org; Mon, 01 Dec 2025 19:16:11 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQ9NX-002baT-30 for pgsql-hackers@postgresql.org; Mon, 01 Dec 2025 19:16:11 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id BC4DF1D0018F; Mon, 1 Dec 2025 14:16:04 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Mon, 01 Dec 2025 14:16:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm2; t=1764616564; x= 1764702964; bh=WgSlimLo894CJhUlS1uGseus2RlOdkbyhLYJp7g5c74=; b=Y 1NlLc3ETNGxqeYPR9N2BJMDk+hX8k9jMbrBPY0MESRW6lBOluR5G5MrE+TbDRBSm 7gEgl+0/O+P2fi2DhW0K6s2mxCUMjdz1I7s0RTqIOlO2npieZb4v/XQ7ymUGx+WL 9mN0mU57vckzX5MqeivtDQYenhGatD5u43K/eytitJWOhKbCEYQ+lcqi881slJTl qiVD+5hKDVUe1g6fpodKLwEN900ELNadQ/A0o7m81fPaK2e/P7vX2O27Ie8b3zG+ omYpHg+8TrPI8+Q9UrFDsqjK86DsNkd0tGwRsIm1Kax+GWpcrZsPwkWaEufEeQd4 Y3nCUczi/oIHwmBpr1XAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1764616564; x=1764702964; bh=W gSlimLo894CJhUlS1uGseus2RlOdkbyhLYJp7g5c74=; b=mgMPXkZbJ6v+zYMta /+VkNG8IX/XVvjDCLjhYh25NV4xRFeRkDOTyac87usMBof58xurRsDVvuW+7Y7Mu 7BnZRiHZmLTXfIJR7sxWXP1OFqbUytK6nsA6SaVQpNzIyYfmPBEqqtZpfInRb4oA 9O9HpQ6EHLa9OeRLQ3zthNOjcHuEycZfgHUmOxGkpHO8wO26MZ51bYiihb2FlC+I rTNTHt4TszwHR1DWbHhyu0OJdCWt4dTg9yva4Y+PDqqmsWLZUWmf2RwYplQccsp1 K7ri3c3rtmKrW3y27LgqAgo6bdO0WZfvqnznAXODw0R7clTYPWhPCXTf3jjYM0SP Md1Rw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvheekheefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeevheduvdevgfeguedttdekgeelkedtheefleelfffhhfdutefgieeg uedvudfhueenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmpdhtfihith htvghrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheprghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhope efpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehnrghthhgrnhgusghoshhsrghr thesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpoh hsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdr uhhs X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Dec 2025 14:16:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1764616561; bh=OKFU/X9iRUts+M9MOj5t4mHI/kP8FG+GZOSMtqAXiQ0=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=EgtRSnaoUrKMVb0ObRq2fmv/JHBbtYG7w4mTSqLZ5WFGeDUtXsG9Ctkf+At/CwEJh MOafvHj0mU6S+N/zSfaOZoKE/eFGgtbOGSmOHYJVexTCJsbt//6c+pNgHln9NsK1jP rxrjIyZh5NaIrqBkSfTaV5np3C7Ttb0r+lHSiC7fzsx581mYcMTD2DiRuKlF+YI94q lZF6UyxBB41qPPcYB9jc8+GGwvGFs/BwoFEaqeUeeLtYsjtPj2lLpRECS1GTf0XfPU oS18OquRwE33YLVvl9dVidhcRjrvRgyLOS+Zhkzwxi1W2YUcoZlXIg3ZYfz1DMSzwh 6EXGrZQ3W08MA== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id C8CBF78; Mon, 01 Dec 2025 20:16:01 +0100 (CET) Date: Mon, 1 Dec 2025 20:16:01 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Tom Lane Cc: Nathan Bossart , pgsql-hackers@postgresql.org Subject: Re: split tablecmds.c Message-ID: <202512011910.rfkycd4x7mcg@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <213385.1764615541@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Dec-01, Tom Lane wrote: > I didn't do any math about it, but that's got to be a far faster rate > of expansion than the overall PG code base. Maybe partitioning is > largely to blame? Perhaps analyzing what functionality got added > here in the past dozen or so years would yield some ideas for how to > split it. Since 2015, with a cutoff of at least 50 lines added or removed: 199 lines added by: bdc3d7fa237 (Return ObjectAddress in many ALTER TABLE sub-routines, 2015-03-25) 61 lines added by: e42375fc812 (Retain comments on indexes and constraints at ALTER TABLE ... TYPE ..., 2015-07-14) 1313 lines added by: f0e44751d71 (Implement table partitioning., 2016-12-07) 58 lines added by: 3957b58b888 (Fix ALTER TABLE / SET TYPE for irregular inheritance, 2017-01-09) 74 lines removed by 2f5c9d9c9ce (Tweak catalog indexing abstraction for upcoming WARM, 2017-01-31) 283 lines added by: 32173270536 (Identity columns, 2017-04-06) 55 lines removed by 3ec76ff1f2c (Don't explicitly mark range partitioning columns NOT NULL., 2017-05-18) 58 lines removed by b08df9cab77 (Teach predtest.c about CHECK clauses to fix partitioning bugs., 2017-06-14) 131 lines added by: 6f6b99d1335 (Allow a partitioned table to have a default partition., 2017-09-08) 66 lines added by: af20e2d728e (Fix ALTER TABLE code to update domain constraints when needed., 2017-11-01) 59 lines removed by ef6087ee5fa (Minor preparatory refactoring for UPDATE row movement., 2018-01-04) 531 lines added by: 8b08f7d4820 (Local partitioned indexes, 2018-01-19) 67 lines added by: eb7ed3f3063 (Allow UNIQUE indexes on partitioned tables, 2018-02-19) 136 lines added by: 86f575948c7 (Allow FOR EACH ROW triggers on partitioned tables, 2018-03-23) 121 lines added by: 3de241dba86 (Foreign keys on partitioned tables, 2018-04-04) 86 lines added by: 5dfd1e5a669 (Logical decoding of TRUNCATE, 2018-04-07) 54 lines added by: dfa60814198 (Fix tablespace handling for partitioned indexes, 2018-11-03) 237 lines removed by 578b229718e (Remove WITH OIDS support, change oid catalog column visibility., 2018-11-20) 77 lines added by: 3b174b1a355 (Fix missing values when doing ALTER TABLE ALTER COLUMN TYPE, 2019-01-10) 306 lines added by: 03afae201f0 (Move CloneForeignKeyConstraints to tablecmds.c, 2019-01-18) 67 lines added by: 0464fdf07f6 (Create action triggers when partitions are detached, 2019-01-21) 69 lines added by: bbb96c3704c (Allow ALTER TABLE .. SET NOT NULL to skip provably unnecessary scans., 2019-03-13) 84 lines removed by d25f519107b (tableam: relation creation, VACUUM FULL/CLUSTER, SET TABLESPACE., 2019-03-28) 131 lines added by: fc22b6623b6 (Generated columns, 2019-03-30) 588 lines added by: f56f8f8da6a (Support foreign keys that reference partitioned tables, 2019-04-03) 82 lines added by: f4a3fdfbdcd (Avoid order-of-execution problems with ALTER TABLE ADD PRIMARY KEY., 2019-04-23) 61 lines added by: 1fa846f1c9a (Fix cloning of row triggers to sub-partitions, 2020-01-02) 159 lines added by: f595117e24a (ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION, 2020-01-14) 280 lines added by: 1281a5c907b (Restructure ALTER TABLE execution to fix assorted bugs., 2020-01-15) 64 lines added by: afccd76f1cc (Fix detaching partitions with cloned row triggers, 2020-04-21) 51 lines added by: 086ffddf365 (Fix several DDL issues of generated columns versus inheritance, 2020-05-06) 55 lines removed by f1fcf2d3b2e (Fix timing issue with ALTER TABLE's validate constraint, 2020-07-14) 84 lines added by: 50289819230 (Fix handling of CREATE TABLE LIKE with inheritance., 2020-08-21) 229 lines added by: bbe0a81db69 (Allow configurable LZ4 TOAST compression., 2021-03-19) 352 lines added by: 71f4c8c6f74 (ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY, 2021-03-25) 92 lines added by: a4d75c86bf1 (Extended statistics on expressions, 2021-03-26) 125 lines added by: 8ff1c94649f (Allow TRUNCATE command to truncate foreign tables., 2021-04-08) 60 lines added by: a970edbed30 (Fix ALTER TABLE / INHERIT with generated columns, 2021-05-04) 120 lines added by: 6f70d7ca1d1 (Have ALTER CONSTRAINT recurse on partitioned tables, 2021-05-05) 105 lines added by: 2ed532ee8c4 (Improve error messages about mismatching relkind, 2021-07-08) 60 lines added by: b0483263dda (Add support for SET ACCESS METHOD in ALTER TABLE, 2021-07-28) 85 lines added by: d6f96ed94e7 (Allow specifying column list for foreign key ON DELETE SET actions, 2021-12-08) 283 lines added by: f4566345cf4 (Create foreign key triggers in partitioned tables too, 2022-01-05) 668 lines added by: e056c557aef (Catalog NOT NULL constraints, 2023-04-07) 668 lines removed by 9ce04b50e12 (Revert "Catalog NOT NULL constraints" and fallout, 2023-04-12) 753 lines added by: b0e96f31198 (Catalog not-null constraints, 2023-08-25) 102 lines added by: 04e485273b5 (Move BuildDescForRelation() from tupdesc.c to tablecmds.c, 2023-10-05) 137 lines added by: 5d06e99a3cf (ALTER TABLE command to change generation expression, 2024-01-04) 159 lines added by: 69958631570 (Support identity columns in partitioned tables, 2024-01-16) 56 lines added by: f7cf9494bad (Split some code out from MergeAttributes(), 2024-01-26) 146 lines added by: 34768ee3616 (Add temporal FOREIGN KEY contraints, 2024-03-24) 105 lines added by: 374c7a22904 (Allow specifying an access method for partitioned tables, 2024-03-25) 320 lines added by: 1adf16b8fba (Implement ALTER TABLE ... MERGE PARTITIONS ... command, 2024-04-07) 411 lines added by: 87c21bb9412 (Implement ALTER TABLE ... SPLIT PARTITION ... command, 2024-04-07) 51 lines added by: d9f686a72ee (Fix restore of not-null constraints with inheritance, 2024-04-18) 828 lines removed by 6f8bb7c1e96 (Revert structural changes to not-null constraints, 2024-05-13) 150 lines removed by 8aee330af55 (Revert temporal primary keys and foreign keys, 2024-05-16) 785 lines removed by 3890d90c150 (Revert support for ALTER TABLE ... MERGE/SPLIT PARTITION(S) commands, 2024-08-24) 146 lines added by: 89f908a6d0a (Add temporal FOREIGN KEY contraints, 2024-09-17) 51 lines added by: d69a3f4d70b (Introduce ATT_PARTITIONED_TABLE in tablecmds.c, 2024-09-19) 167 lines added by: 53af9491a04 (Restructure foreign key handling code for ATTACH/DETACH, 2024-10-22) 390 lines added by: 14e87ffa5c5 (Add pg_constraint rows for not-null constraints, 2024-11-08) 52 lines added by: 9321d2fdf80 (Fix collation handling for foreign keys, 2024-11-15) 59 lines added by: 86374c9a0e3 (Split ATExecValidateConstraint into reusable pieces, 2025-01-16) 58 lines added by: b663b9436e7 (Allow NOT VALID foreign key constraints on partitioned tables, 2025-01-23) 120 lines added by: 83ea6c54025 (Virtual generated columns, 2025-02-07) 85 lines added by: f4e53e10b6c (Add ALTER TABLE ... ALTER CONSTRAINT ... SET [NO] INHERIT, 2025-03-05) 89 lines added by: 1d26c2d2c4b (refactor: Split tryAttachPartitionForeignKey(), 2025-03-11) 57 lines added by: 639238b978f (refactor: Split ATExecAlterConstraintInternal(), 2025-03-25) 309 lines added by: eec0040c4bc (Add support for NOT ENFORCED in foreign key constraints, 2025-04-02) 183 lines added by: a379061a22a (Allow NOT NULL constraints to be added as NOT VALID, 2025-04-07) 50 lines removed by 3231fd04552 (Stop creating constraints during DETACH CONCURRENTLY, 2025-10-11) git log --since '01/01/2015' --format=reference --reverse src/backend/commands/tablecmds.c | while read line; do sha1=$(echo $line | cut -d" " -f1); sz=$(git show $sha1:src/backend/commands/tablecmds.c | wc); prevsz=$currsz; currsz=$(echo $sz | awk '{print $1}'); if [ ! -z "$prevsz" ]; then diff=$(($currsz - $prevsz)); if [ $diff -ge 50 ]; then echo "$diff lines added by: $line" ; elif [ $diff -le -50 ]; then echo "$((-$diff)) lines removed by $line"; fi; fi; done (BTW this output makes it clear to me that commit titles do not end with a period.) -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "You don't solve a bad join with SELECT DISTINCT" #CupsOfFail https://twitter.com/connor_mc_d/status/1431240081726115845