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

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Christoph Berg <myon@debian.org>
Cc: Nathan Bossart <nathan@postgresql.org>, Corey Huinker <corey.huinker@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-04-23T14:33:17Z
Lists: pgsql-hackers

Attachments

On Wed, Apr 23, 2025 at 04:01:33PM +0200, Christoph Berg wrote:
> 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.

I suspect this is due to commit 3d351d9, which started using -1 for
reltuples before the first vacuum/analyze.  Before that, we set it to 0,
which could also mean the table is empty.  --missing-stats-only checks for
reltuples != 0.

My first reaction is that we should just remove the reltuples != 0 check.
That means vacuumdb might analyze some empty tables, but that doesn't seem
too terrible.

-- 
nathan

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.