Re: regarding statistics retaining with 18 Upgrade

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Robert Treat <rob(at)xzilla(dot)net>, Rambabu V <ram(dot)wissen(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: regarding statistics retaining with 18 Upgrade
Date: 2025-11-18 16:00:05
Message-ID: aRyYBRIJW0PBH7De@momjian.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)momjian(dot)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(at)momjian(dot)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(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Do not let urgent matters crowd out time for investment in the future.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-11-18 16:19:24 Re: pg_plan_advice
Previous Message Fujii Masao 2025-11-18 15:59:00 Allow GUC settings in CREATE SUBSCRIPTION CONNECTION to take effect