vacuumdb --missing-stats-only and pg_upgrade from PG13

Christoph Berg <myon@debian.org>

From: Christoph Berg <myon@debian.org>
To: Nathan Bossart <nathan@postgresql.org>, Corey Huinker <corey.huinker@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-04-23T14:01:33Z
Lists: pgsql-hackers
Re: To Nathan Bossart
> > Update guidance for running vacuumdb after pg_upgrade.
> > 
> > Now that pg_upgrade can carry over most optimizer statistics, we
> > should recommend using vacuumdb's new --missing-stats-only option
> > to only analyze relations that are missing statistics.
> 
> I've been looking at vacuumdb --missing-stats-only because Debian's
> pg_upgradecluster is using that now.

The reason I was looking closely yesterday is because Debian's
regression tests were tripping over it, but I only figured out the
problem today:

If I create a table in a PG13-or-earlier cluster, never ANALYZE it,
and then pg_upgrade to 18 and run vacuumdb --analyze-only
--missing-stats-only, the table will not get analyzed. The only table
visited there is pg_largeobject.

Upgrades from 14..17 are fine.

Christoph



Commits

  1. Further adjust guidance for running vacuumdb after pg_upgrade.

  2. vacuumdb: Don't skip empty relations in --missing-stats-only mode.

  3. Update guidance for running vacuumdb after pg_upgrade.

  4. Redefine pg_class.reltuples to be -1 before the first VACUUM or ANALYZE.