Re: vacuumdb changes for stats import/export - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: vacuumdb changes for stats import/export
Date
Msg-id CAKFQuwa2-oW__J7gAcVKgZnx658qBx9GknwL-wqX_0VvDc1EBQ@mail.gmail.com
Whole thread Raw
In response to Re: vacuumdb changes for stats import/export  (Bruce Momjian <bruce@momjian.us>)
Responses Re: vacuumdb changes for stats import/export
List pgsql-hackers


On Sat, Jul 26, 2025, 07:23 Bruce Momjian <bruce@momjian.us> wrote:
On Wed, Jul 23, 2025 at 02:45:10PM +0200, Frédéric Yhuel wrote:
>
>
> On 3/18/25 22:37, Nathan Bossart wrote:
> > Committed with the following small changes:
>
> Hi, I don't really understand this sentence in
> doc/src/sgml/ref/vacuumdb.sgml:
>
> > This option prevents vacuumdb from deleting existing statistics so that
> the query optimizer's choices do not become transiently worse.
>
> I thought that the point was to avoid unnecessary post-upgrade analyzes?

So, the full paragraph is:

+        Only analyze relations that are missing statistics for a column, index
+        expression, or extended statistics object.  This option prevents
+        <application>vacuumdb</application> from deleting existing statistics
+        so that the query optimizer's choices do not become transiently worse.

What it is trying to say is that if you run vacuumedb without this
option, not only will it analyze all tables, including ones that already
have statistics, but will drop statistics on this tables that already
have statistics for a brief period while it installs new statistics.
During that period, the optimizer will not have any statistics for the
table.  Is there a clearer way to state this?

Statistics are transactional.  Without this option specified are we really removing them and commiting prior to computing and saving new ones?  And we are opposed to just changing this behavior and instead prefer to add an option that at first glance seems like everyone should use?

"If not specified the system will analyze all statistics-capable objects in alphabetical order.  Specifying this option then limits the result to only those objects that do not already have statistics.". That may not be how the feature strictly behaves but that would seem to be all one would expect it to do.

David J.

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: vacuumdb changes for stats import/export
Next
From: Bruce Momjian
Date:
Subject: Re: vacuumdb changes for stats import/export