Re: AW: No result when selecting attstattarget from pg_attribute

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: "William Sescu (Suva)" <william(dot)sescu(at)suva(dot)ch>, 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: AW: No result when selecting attstattarget from pg_attribute
Date: 2019-11-28 15:23:33
Message-ID: cb254ce872c8e01d42a54ef2dcb2f4c90459c679.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2019-11-28 15:29:09 Re: AW: No result when selecting attstattarget from pg_attribute
Previous Message William Sescu (Suva) 2019-11-28 15:14:13 AW: No result when selecting attstattarget from pg_attribute