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 1vwuVl-003S8I-0c for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Mar 2026 04:04:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwuVj-00FGPs-0T for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Mar 2026 04:03:59 +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 1vwuVi-00FGPk-2d for pgsql-hackers@lists.postgresql.org; Mon, 02 Mar 2026 04:03:58 +0000 Received: from mail-dl1-x1235.google.com ([2607:f8b0:4864:20::1235]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vwuVf-00000001xzw-2o5r for pgsql-hackers@lists.postgresql.org; Mon, 02 Mar 2026 04:03:58 +0000 Received: by mail-dl1-x1235.google.com with SMTP id a92af1059eb24-1270adc5121so4895070c88.0 for ; Sun, 01 Mar 2026 20:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772424234; cv=none; d=google.com; s=arc-20240605; b=Y9JfALTmnLO5lJTEaXzxuoi64ZbasozsodzmmCiWlVBG6xAFKUXOIBD8HXV9bgjlZY S9gjkG+MofnqppHBU2qfxRyGCsE2w5+1NDpTfAIqUXCxyraOpkwUeFhaeNRghU5RxLFC XAem1sBBdaQh13bDOzCLQcLsQyVT8l8pKKNVrAMHglLi7vdFy4fgl+jeb8HCOmUS848j W3MPxcWHmPHIZgahTR2HAdcTjDwC9N8OrteTFR1o2WYeT2phEgrj3n3HlSiOG3wNE1YE 828B84v3ZhWHjW5nlPMcBW7WxOIfIz5cWvtAwjS4nWoCqc/+bz6CI4JutGTlyAWkVf+D 5z+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=j44lZcJo9EIfTTEP192aQ8JFV8/3KfX1/dlCOiHRCyI=; fh=2MLZz3HaxSRbcE7hgZSXY9Hb5cQByuz4esXJXt5MU7s=; b=W44va+tPSUOGdJsl7OeUFJl+rmwtnmpvsDv1bXxfacep5I0U1jeG/yIPMoTZmZjxr0 7ZYeuXpNTnjGXBF6BURkvpsnp6p74oK/MbMyC6E65XLVkPaDZRxZDgwo24zA5DjWryCX 4uwQZUrohTiq1KSGrbi/g5s8begu3Mwl3ufF0Z9OyiBZ54VcD8Ha1NVmG+z1LJwdHuNi 9tT7qkixFLQsldZxcWP52kpy5v+ogkpkDBA5b3Gx6o0K1nU6yNC+LJagh4Bm4fw30ykm YBPMbnOQ012LYBgmEkOuZSSqvnnDn14qy4Hhw/wL/EkoMqeJ7Lr6+0DAcPlKurHI984B 6nuw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772424234; x=1773029034; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=j44lZcJo9EIfTTEP192aQ8JFV8/3KfX1/dlCOiHRCyI=; b=LTc6xiJkOxSHnYoIUaQFg5Oaq5Hlw26/x4PTRYpOGKPpd9chTQH1k9whikkhzPfNd7 PApeKIXsfKv6mxEyG+uvKp1McdwaYL97qws58Jfjk5gE9gY6ZZyNnhkmNeCBgvPJfWTF cyKGqTP1bMXl8s5RUv16WpKh+teMCRXovwHE7jhVPTpwuuW0sTbUrdqxy3l7v2FgX3eH 8WovB8/G1LOho8vGsyoVR4XF5iWmir4Bxl7EoOItU7NowfJJF97bHHl8FYTPsmwY5S2T ftaJtPC+58f7DVVvhJ1EDVVPn53AW0u0+FLUvh589XfEJRLuyss5aN7cgo5GSfOKhJDC YRwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772424234; x=1773029034; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j44lZcJo9EIfTTEP192aQ8JFV8/3KfX1/dlCOiHRCyI=; b=HSUUaX8RD5O1GPjZ4yjMf1H5eOHdF7lsDbyJHL+8Eow+ADAOKxR+hNMeiAZL6CQIYP J/vuxx/isvdxcSi8+ce8bskLJNnmllK5TRx25X6RbhK7247nDOUYUSLGiA7VotbClEK+ 9dldhdmky0utETmHWajjWD1es80Ky2bYZPkMPLAolgebPOysMlLE9MGqRhbSXq0gIE8o wYdTRLcH+7O9u+UEktZrTqkzaCoe+VPliOesH+5ihfd/LlmrhLFhz90AbHYhqB3Wuv5L EOFe1TQwCEVm0pVqgBw7R/GNlwfopwmWmfX1YPHgZtSb/QBTLvInUV3rfHY3MXsqNTed 2CrQ== X-Forwarded-Encrypted: i=1; AJvYcCXz4Hxt97iShVcneJBqitArHyJEfs6q3RKQr6tbV4zS50W//lzywY5RML/+Xx+OM5d79uxjHMT/I0hpRuHO@lists.postgresql.org X-Gm-Message-State: AOJu0YwCWVeQyYTQUWSwjWJ4/O7YT7EE6FnksY1injtJn7XxvAlmPaRA tLcoO/Qfa26rHgmGwhldc2GMNRUFY2QI8gwPgxaIVbdCILh5D2QnV4JUft3c4M75p5GMTQQbK8r vwwKqtegln58LHKG082H34FsRWPW20dA= X-Gm-Gg: ATEYQzzmTyE0/exSGW9LNlRuNqbxquuknQSTF0hno/OcPbe4GXHgdhUYngRPkkTPBhu ZgDM+PTuSHbJiLYPqXuXfHZYsUOnceZXkLLeFNkPS/HZNw9P3Fwnh1cOrnXEBkAEDPYFp24Op9p zASw3bNR3ScjRox/GbYLiRBkEfIOk60r0JeLqEfD8FPxBfj+d0hW+6gBj04Q02V/YKk9w0qut3G 92vou1cBNjI4N4DcvPAf/3tf2DtyFfrLQC7BK3+eVhlaE6Z3bWCeEeBZjebE/V7BAZbrnpLGTQI HDH6mn2ccTjPUHgk3garerlKbafHvE0EbbkAFrH9/xabU8UxfJx/h50jwB7IKg3PUwM+auaQLaX D3Ay1t+LKw2UB1Dy4FUomDyOp X-Received: by 2002:a05:7022:2392:b0:122:2f4:b285 with SMTP id a92af1059eb24-1278fcb63b5mr4062399c88.25.1772424234049; Sun, 01 Mar 2026 20:03:54 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Corey Huinker Date: Sun, 1 Mar 2026 23:03:42 -0500 X-Gm-Features: AaiRm50GWaz52vnYi5CFfwVG4KeZNfJZUXomia0lAe1b_e4RjmkZ-T7nKuDkL5s Message-ID: Subject: Re: Add starelid, attnum to pg_stats and leverage this in pg_dump To: Sami Imseih Cc: nathandbossart@gmail.com, pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000dca5a8064c02ac33" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000dca5a8064c02ac33 Content-Type: text/plain; charset="UTF-8" > Ideally, we would want the OID and attnum to be first columns to match > the pg_stat_activity/pg_stat_progress style, but that will be too invasive. > I don't think there is an order that will make anyone happy, let alone everyone. The existing columns (schemaname, tablename, attname, inherited) constitute a grain, so its hard to separate them. Once we add attnum, that can replace attname in the above grain. Once we add starelid/tableid, then that can be combined win inherited and either attnum/attname for a grain. The ordering of these columns will largely fall down to the perspective of the person seeking to use it. > > - This should be int2 > - Maybe for the describtion, it should be something like: > +1 > > "The number of the column, as in > pg_attribute.attnum" > We don't do that for attname, why would attnum be different? > > > + > + > + starelid oid > + > + > + ID of the relation > + > + > > This should indicate it is a reference to pg_class.oid, like so: > I went with pg_attribute, but the reference is there now. > > Maybe "ID of the table or index" is better, since this can only be a > table or index > for pg_stats. > I went with table, because it matches the tablename definition (i.e. it is equally inaccurate). > > I dislike the existing "pg_stats.tablename", since this can also be an > expression index. > "pg_stats.relation" with a description of "Name of table or index" is > more appropriate. > It is a change that we can possibly make in a major version. Looked > through the archives, > and did not see this being reported/discussed. > I don't see it changing in any version, minor or major. > > v1-0002: > > I examined the version variants of getAttributeStats and all looks good, > and also ran a test on a 18 and 19 server version with the patched pg_dump > client and all looks good. > > One minor comment is: > > > + pg_fatal("statistics table oid information missing"); > > > I noticed in other pg_fatal messages, we include OIDs > > pg_fatal("could not find function definition for function > with OID %u", > cast->castfunc); > > Should we do the same here? > If I had the oid, I wouldn't have the error. :) I've modified the error message to give the namespace/tag of the entry. Will post revised patch later. --000000000000dca5a8064c02ac33 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Ideally, we would want the OID and attnum to be first columns to match
the pg_stat_activity/pg_stat_progress style, but that will be too invasive.=

I don't think there is an order th= at will make anyone happy, let alone everyone.

The= existing columns (schemaname, tablename, attname, inherited) constitute a = grain, so its hard to separate them.

Once we add a= ttnum, that can replace attname in the above grain. Once we add starelid/ta= bleid, then that can be combined win inherited and either attnum/attname fo= r a grain. The ordering of these columns will largely fall down to the pers= pective of the person seeking to use it.

=C2=A0

- This <type> should be int2
- Maybe for the describtion, it should be something like:
<= div>
+1
=C2=A0

=C2=A0 "The number of the column, as in
<structname>pg_attribute</structname>.<structfield>attnum= </structfield>"

We don't= do that for attname, why would attnum be different?
= =C2=A0


+=C2=A0 =C2=A0 =C2=A0<row>
+=C2=A0 =C2=A0 =C2=A0 <entry role=3D"catalog_table_entry">&= lt;para role=3D"column_definition">
+=C2=A0 =C2=A0 =C2=A0 =C2=A0<structfield>starelid</structfield>= <type>oid</type>
+=C2=A0 =C2=A0 =C2=A0 </para>
+=C2=A0 =C2=A0 =C2=A0 <para>
+=C2=A0 =C2=A0 =C2=A0 =C2=A0ID of the relation
+=C2=A0 =C2=A0 =C2=A0 </para></entry>
+=C2=A0 =C2=A0 =C2=A0</row>

This should indicate it is a reference to pg_class.oid, like so:

I went with pg_attribute, but the reference is th= ere now.
=C2=A0

Maybe "ID of the table or index" is better, since this can only b= e a
table or index
for pg_stats.

I went with table, becaus= e it matches the tablename definition (i.e. it is equally inaccurate).
=C2=A0

I dislike the existing "pg_stats.tablename", since this can also = be an
expression index.
"pg_stats.relation" with a description of "Name of table or = index" is
more appropriate.
It is a change that we can possibly make in a major version. Looked
through the archives,
and did not see this being reported/discussed.

I don't see it changing in any version, minor or major.

=C2=A0

v1-0002:

I examined the version variants of getAttributeStats and all looks good, and also ran a test on a 18 and 19 server version with the patched pg_dump<= br> client and all looks good.

One minor comment is:


+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pg_f= atal("statistics table oid information missing");


I noticed in other pg_fatal messages, we include OIDs

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pg_fatal("could not find fun= ction definition for function
with OID %u",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0cast->castfunc);

Should we do the same here?

If I had th= e oid, I wouldn't have the error. :)

I've modifie= d the error message to give the namespace/tag of the entry. Will post revis= ed patch later.
--000000000000dca5a8064c02ac33--