Re: Add starelid, attnum to pg_stats and leverage this in pg_dump

Sami Imseih <samimseih@gmail.com>

From: Sami Imseih <samimseih@gmail.com>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2026-03-12T21:08:34Z
Lists: pgsql-hackers
> Apologies for the delay. I thought I had posted this. I rebased it against a630ac5c2016e52 (current HEAD).

Thanks!

just a few things.


v5-0001:

+-- Set up convenience views
+--
+CREATE VIEW stats_import.pg_stats_check AS

It will be good to add more commentary here to the next person adding
a test, and mention
that only stable values should be included in this view. what do you think?

v5-0002:

This is the wrong link. It should be catalog-pg-attribute and not
catalog-pg-class

+       (references <link
linkend="catalog-pg-class"><structname>pg_attribute</structname></link>.<structfield>attrelid</structfield>)

and a few occurrences where the link to pg_statistic_ext is pointing
to catalog-pg-class:

+       (references <link
linkend="catalog-pg-class"><structname>pg_statistic_ext</structname></link>.<structfield>stxrelid</structfield>)


v5-0003:

LGTM


--
Sami Imseih
Amazon Web Services (AWS)



Commits

  1. pg_dump: Simplify query for retrieving attribute statistics.

  2. Add more columns to pg_stats, pg_stats_ext, and pg_stats_ext_exprs.

  3. Add convenience view to stats import test.