On Thu, 2019-11-28 at 15:14 +0000, William Sescu (Suva) wrote: > Thank you Tom for clarification. However, in regards of pg_upgrade, which does not transfer statistics, how do I know > how to create the "CREATE STATISTICS" on the new PostgreSQL version? > > e.g. Developers created a whole bunch of "CREATE STATISTICS" on all kind of tables, which ends up in pg_statistic_ext view. > > select * from pg_statistic_ext; > stxrelid | stxname | stxnamespace | stxowner | stxkeys | stxkind | stxndistinct | stxdependencies > ----------+---------+--------------+----------+---------+---------+--------------+---------------------- > 35600 | s1 | 16579 | 16569 | 1 2 | {f} | | {"1 => 2": 1.000000} > > Is there any way how I can translate the view entries into into a SQL again? > > CREATE STATISTICS s1 (dependencies) ON a, b FROM t1; You are worrying without need. While the actual statistics won't be upgraded, the *definition* for extended statistics will be. So your CREATE STATISTICS won't vanish during an upgrade. You'll have to ANALYZE after upgrading so that PostgreSQL collects the extended statistics. Extended statistics are stored in the "pg_statistic_ext" catalog. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com