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.94.2) (envelope-from ) id 1tmeDf-008Pum-5M for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2025 19:34:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tmeDe-006yFY-1i for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2025 19:34:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmeDd-006yFP-O2 for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2025 19:34:21 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tmeDa-000Wv6-2E for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2025 19:34:20 +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 51OJYDHH1468523; Mon, 24 Feb 2025 14:34:13 -0500 From: Tom Lane To: Jeff Davis cc: Corey Huinker , Andres Freund , Michael Paquier , jian he , Nathan Bossart , Bruce Momjian , Matthias van de Meent , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org Subject: Re: Statistics Import and Export In-reply-to: <6d1c72b06fe3645a50897381d71ff1b39085abf6.camel@j-davis.com> References: <3670503.1740173078@sss.pgh.pa.us> <3728741.1740178078@sss.pgh.pa.us> <97b451228227c555be1a4f79c4a62ddec9a74f06.camel@j-davis.com> <1457469.1740419458@sss.pgh.pa.us> <6d1c72b06fe3645a50897381d71ff1b39085abf6.camel@j-davis.com> Comments: In-reply-to Jeff Davis message dated "Mon, 24 Feb 2025 10:54:43 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1468521.1740425653.1@sss.pgh.pa.us> Date: Mon, 24 Feb 2025 14:34:13 -0500 Message-ID: <1468522.1740425653@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jeff Davis writes: > We certainly want attnames for tables to keep it working reasonably > well for cases where the user might be doing something more interesting > than a binary upgrade, as you point out. But attribute numbers for > indexes seem much more reliable: an index with a different attribute > order is a fundamentally different index. Right. We went through pretty much this reasoning, as I recall, when we invented ALTER INDEX ... SET STATISTICS. The original version used a column name like ALTER TABLE did, and we ran into exactly the present problem that the names aren't too stable across dump/restore, and we decided that index column numbers would do instead. You can't add or drop a column of an index, nor redefine it meaningfully, except by dropping the whole index which will make any associated stats go away. The draft patch I posted allows callers to use attname or attnum at their option, because I didn't see a reason to restrict that. But I envisioned that pg_dump would always use attname for table columns and attnum for index columns. regards, tom lane