Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8xkH-00067q-2q for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jul 2021 04:34:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m8xkG-0002yb-2E for pgsql-bugs@arkaria.postgresql.org; Thu, 29 Jul 2021 04:34:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8xkF-0002xq-Rl for pgsql-bugs@lists.postgresql.org; Thu, 29 Jul 2021 04:34:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m8xkD-0007lj-Pw for pgsql-bugs@lists.postgresql.org; Thu, 29 Jul 2021 04:34:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 16T4WqMM683333; Thu, 29 Jul 2021 00:32:52 -0400 From: Tom Lane To: David Rowley cc: "David G. Johnston" , =?UTF-8?B?5b635ZOl?= , PostgreSQL mailing lists Subject: Re: BUG #17127: drop column cann't delete from pg_attribute, so it will up to 1600 limits soon In-reply-to: References: <17127-f973fb9d41bae9ca@postgresql.org> Comments: In-reply-to David Rowley message dated "Thu, 29 Jul 2021 16:14:49 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <683331.1627533172.1@sss.pgh.pa.us> Date: Thu, 29 Jul 2021 00:32:52 -0400 Message-ID: <683332.1627533172@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Thu, 29 Jul 2021 at 16:08, David G. Johnston > wrote: >> So, it is not a bug, and, IMO, it is not a limitation worth removing. > I'm not sure if I agree that it's "explicitly documented". All that > text mentions is that you can't have more than 1600 columns in a table > at once. What the OP is complaining about are that attnums are not > recycled and that if you continually add and drop columns you can run > out well before you have 1600 columns. Right, but why is that a usage pattern that is worth the very large increment in complexity that would be involved in supporting it? The fundamental reason why we can't just "recycle attnums" is that the attnums are effectively primary keys, ie permanent unique identifiers, for columns. A table's attnums propagate into views on the table, foreign key data in other tables, etc etc. So renumbering attnums would involve updating those other objects and therefore taking exclusive locks on them, which creates a lot of issues. It's possible that some of this could be dodged if we ever finish the project of decoupling logical and physical column positions. What was being talked about there was having three identifiers for a column (permanent ID, logical index, physical index). If we didn't restrict the range of permanent IDs then the problem goes away, at least till you overrun an int16 or int32. But anyway, I'm skeptical that there is a use-case here that justifies a lot of work to fix. Why is it a good idea to drop and re-add a column over and over? regards, tom lane