Re: vacuumdb changes for stats import/export

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Frédéric Yhuel <frederic.yhuel@dalibo.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, Corey Huinker <corey.huinker@gmail.com>, Bruce Momjian <bruce@momjian.us>, John Naylor <johncnaylorls@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>, Jeff Davis <pgsql@j-davis.com>, jian he <jian.universality@gmail.com>, Matthias van de Meent <boekewurm+postgres@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Magnus Hagander <magnus@hagander.net>, Stephen Frost <sfrost@snowman.net>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Peter Smith <smithpb2250@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, "alvherre@alvh.no-ip.org" <alvherre@alvh.no-ip.org>
Date: 2025-07-28T16:22:29Z
Lists: pgsql-hackers
On Monday, July 28, 2025, Frédéric Yhuel <frederic.yhuel@dalibo.com> wrote:

>
>
> On 7/28/25 16:47, Nathan Bossart wrote:
>
>> I can't remember who wrote this line, but it was borrowed from the
>> --analyze-in-stages description.  The point is that if you use
>> --analyze-in-stages without --missing-stats-only, there will be a period
>> where existing statistics will be replaced with ones generated with lower
>> statistics targets.
>>
>
> Aha, it makes sense now, thank you!
>
> Obviously, this wording isn't clear enough.  We might
>> need to either remove that sentence or add "When used in conjunction with
>> --analyze-in-stages..."
>>
>
> I vote for the second option.
>
>
Makes sense.  This does beg the question - what happens if a column is left
with a lower statistics target than what would be applied during an
analyze, but one is present?  I don’t see where the statistics target is
saved anywhere.  Can we start recording that piece of data and teach
analyze in stages to just never go backwards - reporting any it had to skip
to adhere to that rule.  Seems like a better policy than missing-only.

David J.

Commits

  1. doc: Adjust documentation for vacuumdb --missing-stats-only.

  2. Update guidance for running vacuumdb after pg_upgrade.

  3. vacuumdb: Add option for analyzing only relations missing stats.

  4. vacuumdb: Teach vacuum_one_database() to reuse query results.