Re: AW: No result when selecting attstattarget from pg_attribute - Mailing list pgsql-admin

From Laurenz Albe
Subject Re: AW: No result when selecting attstattarget from pg_attribute
Date
Msg-id cb254ce872c8e01d42a54ef2dcb2f4c90459c679.camel@cybertec.at
Whole thread Raw
In response to AW: No result when selecting attstattarget from pg_attribute  ("William Sescu (Suva)" <william.sescu@suva.ch>)
List pgsql-admin
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




pgsql-admin by date:

Previous
From: "William Sescu (Suva)"
Date:
Subject: AW: No result when selecting attstattarget from pg_attribute
Next
From: Tom Lane
Date:
Subject: Re: AW: No result when selecting attstattarget from pg_attribute