Re: Add starelid, attnum to pg_stats and leverage this in pg_dump - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Add starelid, attnum to pg_stats and leverage this in pg_dump
Date
Msg-id CADkLM=eUR5co+o3PU8M=Fo8rRynj4xf=PFtt2KisD96bdrPEOg@mail.gmail.com
Whole thread
In response to Re: Add starelid, attnum to pg_stats and leverage this in pg_dump  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Add starelid, attnum to pg_stats and leverage this in pg_dump
List pgsql-hackers


On Mon, Mar 9, 2026 at 11:51 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
On Mon, Mar 09, 2026 at 10:44:58AM -0500, Sami Imseih wrote:
>> Oh, a question I forgot to ask: why wouldn't we do the same thing for
>> pg_stats_ext and pg_stats_ext_exprs?
>
> [...]
>
> If we do add relid there, it will be for consistency only.

It might be only for consistency for now, but it strikes me as something
that could be handy down the road (in which case it'd be nice to minimize
the number of versions that need a fallback).

--
nathan

You're both right. Currently, we fetch extended stats one at a time, thus there's no _immediate_ need to do so.

But "why wait until there is a crisis" is solid reasoning and for that I had already coded up the change. I did have one small problem in that Michael Paquier had hoped that we could get the expr index (-1, -2, etc) on the expressions as that was something that we at least briefly thought we'd need for importing expression statistics. However the existing query uses a SELECT unnest(a), unnest(b) pattern in it, and WITH ORDINALITY is not allowed, and the workarounds I found seemed a bit tortured. Hence, I decided to leave that out so as not to distract from the now accepted patch, and with that out of the way I'll happily inflict that tortured SQL on y'all. 

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD
Next
From: Patrick Reinhart
Date:
Subject: Re: Proposal to allow setting cursor options on Portals