On Wed, Dec 27, 2023 at 09:41:31PM -0500, Corey Huinker wrote: > When I thought about the ability to dump/load statistics in the past, I > usually envisioned some sort of DDL that would do the export and import. > So for example we'd have EXPORT STATISTICS / IMPORT STATISTICS commands, > or something like that, and that'd do all the work. This would mean > stats are "first-class citizens" and it'd be fairly straightforward to > add this into pg_dump, for example. Or at least I think so ... > > Alternatively we could have the usual "functional" interface, with a > functions to export/import statistics, replacing the DDL commands. > > Unfortunately, none of this works for the pg_upgrade use case, because > existing cluster versions would not support this new interface, of > course. That's a significant flaw, as it'd make this useful only for > upgrades of future versions. > > > This was the reason I settled on the interface that I did: while we can create > whatever interface we want for importing the statistics, we would need to be > able to extract stats from databases using only the facilities available in > those same databases, and then store that in a medium that could be conveyed > across databases, either by text files or by saving them off in a side table > prior to upgrade. JSONB met the criteria.
Uh, it wouldn't be crazy to add this capability to pg_upgrade/pg_dump in a minor version upgrade if it wasn't enabled by default, and if we were very careful. -- Bruce Momjian <br...@momjian.us> https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.