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

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add starelid, attnum to pg_stats and leverage this in pg_dump
Date: 2026-03-09 22:42:46
Message-ID: CADkLM=dhYeJtP+8h8k4ULCu-P1pNHmFyDFBm8B0WU6A6i+NgPQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 9, 2026 at 5:04 PM Nathan Bossart <nathandbossart(at)gmail(dot)com>
wrote:

> On Mon, Mar 09, 2026 at 03:28:40PM -0400, Corey Huinker wrote:
> > Presently, I don't think we make any changes to pg_dump, unless Nathan
> > feels strongly that we should. If and when the need for oid-based
> fetching
> > of extended stats becomes necessary, we'll at least have a couple
> versions
> > where the catalog already had the oids handy.
>
> That's fine with me.
>
> --
> nathan
>

I was sidetracked for a bit because the tests (which are accurate) seemed
strange in that pg_stats_ext_exprs would have 2 rows with NULL
inherited...and it took me a bit to realize that that actually makes sense
because the pg_stats_ext_exprs should have one row per expression whether
or not there are stats to match it. If that sounds like it could mess up
vacuumdb, it actually can't, because we base those tests based off
pg_stats_ext not pg_stats_ext_exprs - which does vary according to whether
stats exist for the object or not. I added a comment to the regression test
to that effect.

The new column expr_attnum gives the negative number that a given
expression has in pg_dependencites and pg_ndistinct - as you might imagine,
the number is determined by its order within the list of expressions.

If you want 0003 split into two (one for pg_stats_ext and one for
pg_stats_ext_exprs) I can do that, but they felt like a package deal to me.

Attachment Content-Type Size
v4-0001-Add-tableid-and-attnum-columns-to-pg_stats.patch text/x-patch 76.7 KB
v4-0002-pg_dump-Use-tableid-in-getAttributeStats.patch text/x-patch 8.0 KB
v4-0003-Add-tableid-statid-expr_attnum-columns-to-pg_stat.patch text/x-patch 27.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gyan Sreejith 2026-03-09 22:55:56 Re: [Proposal] Adding Log File Capability to pg_createsubscriber
Previous Message Zsolt Parragi 2026-03-09 22:33:49 Re: Compression of bigger WAL records