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: Nathan Bossart <nathandbossart@gmail.com>
Cc: Corey Huinker <corey.huinker@gmail.com>,
pgsql-hackers@lists.postgresql.org
Date: 2026-03-09T15:44:58Z
Lists: pgsql-hackers
> Oh, a question I forgot to ask: why wouldn't we do the same thing for > pg_stats_ext and pg_stats_ext_exprs? The primary purpose of adding the relid is to optimize queries on pg_statistics in pg_dump. + * * The redundant filter clause on s.tablename = ANY(...) seems * sufficient to convince the planner to use * pg_class_relname_nsp_index, which avoids a full scan of pg_stats. - * This may not work for all versions. + * This seems to work for all version prior to v19, after which we + * will use the starelid, which is simpler. pg_stats_ext and pg_stats_ext_expr do not have the same concern. If we do add relid there, it will be for consistency only. -- Sami Imseih Amazon Web Services (AWS)
Commits
-
pg_dump: Simplify query for retrieving attribute statistics.
- 4b5ba0c4ca52 19 (unreleased) landed
-
Add more columns to pg_stats, pg_stats_ext, and pg_stats_ext_exprs.
- 3b88e50d6c2e 19 (unreleased) landed
-
Add convenience view to stats import test.
- 233bbdf031e4 19 (unreleased) landed