On Sat, 2024-03-30 at 01:34 -0400, Corey Huinker wrote: > > - 002pg_upgrade.pl now dumps before/after databases with --no- > statistics. I tried to find out why some tables were getting their > relstats either not set, or set and reset, never affecting the > attribute stats. I even tried turning autovacuum off for both > instances, but nothing seemed to change the fact that the same tables > were having their relstats reset.
I think I found out why this is happening: a schema-only dump first creates the table, then sets the relstats, then creates indexes. The index creation updates the relstats, but because the dump was schema- only, it overwrites the relstats with zeros. That exposes an interesting dependency, which is that relstats must be set after index creation, otherwise they will be lost -- at least in the case of pg_upgrade. This re-raises the question of whether stats are part of a schema-only dump or not. Did we settle conclusively that they are? Regards, Jeff Davis