Re: vacuumdb changes for stats import/export

From: Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, John Naylor <johncnaylorls(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, alvherre(at)alvh(dot)no-ip(dot)org
Subject: Re: vacuumdb changes for stats import/export
Date: 2025-07-27 10:46:44
Message-ID: 8320fa2e-9200-46e2-b905-4a4d84707020@dalibo.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 7/26/25 21:38, Corey Huinker wrote:
>
>
> It is transactional, mostly.
>
> The attribute stats for the table being analyzed and all attribute stats
> for the dependent indexes that have at least one expression column, plus
> extended stats objects on that table, will be replaced in one atomic
> operation. The old stats were there, commit happens, now the new stats
> are there.
>
> The relation stats (pg_class) happen in-place, non-transactionally. So
> if you had an analyze that got canceled, and some of the relstats had
> been updated on the table or indexes, those would stay as-is.
>

Then it seems very unlikely that the query optimizer's choices become
transiently worse because of that, doesn't it? and this shouldn't be
used to justify this option, IMHO.

How about this? "This option is primarily intended to be used in
post-upgrade scripts to quickly generate minimal optimizer statistics"

> Having said all that, these are very nitpick details that may not need
> to be in our documentation.
>

+1

I've always supposed that the statistics were completely transactional,
I think most users do, and the difference with reality seems small enough.

>
>
>
> /me dons Hat of Pedantry (+2 against simple explanations)
>
> "Specifying this option then limits the result to only tables that are
> missing an attribute statistic, have an index that is missing an
> attribute statistic, or have an extended statistics object that is
> itself missing object statistics".
>
> /me removes hat
>
> "Specifying this option then limits the result to only those tables that
> do not already have complete statistics."
>
> The above phrase is asking the word "complete" to do a lot of heavy
> lifting, covering the dependent indexes and extended statistics objects.
> Specifying "table" makes it clear that any deficit in statistics results
> in the table getting analyzed, not just the single index or extended object.

FWIW I much prefer the last, simple phrase.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2025-07-27 11:53:45 Re: IPC/MultixactCreation on the Standby server
Previous Message Etsuro Fujita 2025-07-27 10:35:59 Re: [(known) BUG] DELETE/UPDATE more than one row in partitioned foreign table