Thread

  1. Re: regarding statistics retaining with 18 Upgrade

    Bruce Momjian <bruce@momjian.us> — 2025-11-18T16:00:05Z

    On Tue, Nov 18, 2025 at 12:41:28PM +0900, Fujii Masao wrote:
    > On Tue, Nov 18, 2025 at 8:56 AM Bruce Momjian <bruce@momjian.us> wrote:
    > >
    > > On Sat, Nov 15, 2025 at 06:52:15PM -0500, Robert Treat wrote:
    > > > On Sat, Nov 15, 2025 at 9:32 AM Bruce Momjian <bruce@momjian.us> wrote:
    > > > > On Sat, Nov 15, 2025 at 06:02:53PM +0800, Rambabu V wrote:
    > > > > > Hi Team,
    > > > > >
    > > > > > seems stats are not retained after upgrade. Below are the artifacts , is it
    > > > > > expected? as per the release notes statistics should be retained.
    > > > >
    > > > > Uh, it is the _optimizer_ statistics that are preserved by pg_upgrade,
    > > > > not the cumulative statistics system:
    > > > >
    > > > >         https://www.postgresql.org/docs/current/monitoring-stats.html
    > > > >
    > > > > Yes, they are easily confused.
    > > > >
    > > >
    > > > I wonder if it might be worth trying to clarify this a little bit
    > > > more... perhaps something like the attached?
    > >
    > > Patch applied back to PG 18, thanks.
    > 
    > Thanks for working on this!
    > 
    >    <para>
    > -   If <option>--statistics</option> is specified,
    > +   When <option>--statistics</option> is specified,
    >     <command>pg_dumpall</command> will include most optimizer statistics in the
    > -   resulting dump file.  However, some statistics may not be included, such as
    > -   those created explicitly with <xref linkend="sql-createstatistics"/> or
    > -   custom statistics added by an extension.  Therefore, it may be useful to
    > +   resulting dump file. This does not include all statistics, such as
    > +   those created explicitly with <xref linkend="sql-createstatistics"/>,
    > +   custom statistics added by an extension, or statistics collected by the
    > +   cumulative statistics system.  Therefore, it may still be useful to
    >     run <command>ANALYZE</command> on each database after restoring from a dump
    >     file to ensure optimal performance.  You can also run <command>vacuumdb -a
    >     -z</command> to analyze all databases.
    > 
    > Since pgupgrade.sgml contains similar text, I think it should be
    > updated as well.
    > For example, something like this:
    
    Yeah, you are probably right.  I didn't see that.  You should apply it
    since it is your patch, thanks.
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        https://momjian.us
      EDB                                      https://enterprisedb.com
    
      Do not let urgent matters crowd out time for investment in the future.