Jeff Davis <pg...@j-davis.com> writes: > On Sat, 2024-03-30 at 20:08 -0400, Tom Lane wrote: >> I haven't looked at the details, but I'm really a bit surprised >> by Jeff's assertion that CREATE INDEX destroys statistics on the >> base table. That seems wrong from here, and maybe something we >> could have it not do. (I do realize that it recalculates reltuples >> and relpages, but so what? If it updates those, the results should >> be perfectly accurate.)
> In the v15 of the patch I was looking at, "pg_dump -s" included the > statistics. The stats appeared first in the dump, followed by the > CREATE INDEX commands. The latter overwrote the relpages/reltuples set > by the former. > While zeros are the right answers for a schema-only dump, it defeated > the purpose of including relpages/reltuples stats in the dump, and > caused the pg_upgrade TAP test to fail. > You're right that there are a number of ways this could be resolved -- > I don't think it's an inherent problem. I'm inclined to call it not a problem at all. While I do agree there are use-cases for injecting false statistics with these functions, I do not think that pg_dump has to cater to such use-cases. In any case, I remain of the opinion that stats are data and should not be included in a -s dump (with some sort of exception for pg_upgrade). If the data has been loaded, then a subsequent overwrite by CREATE INDEX should not be a problem. regards, tom lane