Re: pg_restore handles extended statistics inconsistently with statistics data
Chao Li <li.evan.chao@gmail.com>
From: Chao Li <li.evan.chao@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Corey Huinker <corey.huinker@gmail.com>,
PostgreSQL-development <pgsql-hackers@lists.postgresql.org>,
Michael Paquier <michael.paquier@gmail.com>,
Jeff Davis <pgsql@j-davis.com>
Date: 2026-06-16T07:20:19Z
Lists: pgsql-hackers
> On Jun 16, 2026, at 14:59, Michael Paquier <michael@paquier.xyz> wrote: > > On Tue, Jun 16, 2026 at 02:36:21PM +0800, Chao Li wrote: >> I think the dependency-based matching is better, but what happens if >> the archive is created with --statistics-only? In that case, the >> statistics entries still have dependencies, but the referenced >> parent TOC entries are not present in the archive. See the attached >> test script. It creates the archive with --statistics-only, with the >> new patch, neither table nor index stats are restored: > > I can see your argument in that HEAD can improve the detection in what > gets restored if the dumps only include the stats data, but I don't > really buy that this is a use case interesting to support: one can > also dump the data with the index definition and then filter back the > contents when restoring using --index. So at the end having a tighter > check at the restore is more appealing to me, because it leads to a > more predictible result, like in the scenario I have posted upthread > when a schema has the idea to include tables and indexes with the same > names (unlikely, okay, still). Or in short, don't do that. > > For the case of upgrades one or the other does not really matter, > pg_upgrade treats all the objects in full. > -- > Michael Make sense. Then the new patch looks good to me. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
Commits
-
pg_restore: Use dependency-based matching for STATISTICS DATA
- 477efef089c3 18 (unreleased) landed
- ae39bd23c662 19 (unreleased) landed
-
Fix inconsistencies with pg_restore --statistics[-only]
- 42ffdedcf743 18 (unreleased) landed
- 0dd93de69e80 19 (unreleased) landed