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-09T18:56:19Z
Lists: pgsql-hackers
Attachments
- v3-0002-pg_dump-Use-tableid-in-getAttributeStats.patch (application/octet-stream) patch v3-0002
- v3-0003-Add-tableid-column-to-pg_stats_ext-and-pg_stats_e.patch (application/octet-stream) patch v3-0003
- v3-0001-Add-tableid-and-attnum-columns-to-pg_stats.patch (application/octet-stream) patch v3-0001
>> 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. Can we add the tableid for now (see 0003) and follow-up with another thread with the sql changes to pg_dump? I also corrected v2-0001. The docs were still referencing "starlid" instead of "tableid" -- 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