vacuumdb: Don't skip empty relations in --missing-stats-only mode. Presently, --missing-stats-only skips relations with reltuples set to 0 because empty relations don't get optimizer statistics. However, before v14, a reltuples value of 0 was ambiguous: it could either mean the relation is empty, or it could mean that it hadn't yet been vacuumed or analyzed. (Commit 3d351d916b taught v14 and newer to use -1 for the latter case.) This ambiguity can cause --missing-stats-only to inadvertently skip relations that need optimizer statistics after upgrades to v18 and newer (since reltuples is now transferred from the old cluster).
To fix, simply remove the check for reltuples != 0. This will cause --missing-stats-only to analyze some empty tables, but that doesn't seem too terrible a trade-off. Reported-by: Christoph Berg <m...@debian.org> Reviewed-by: Christoph Berg <m...@debian.org> Discussion: https://postgr.es/m/aAjyvW5_fRGNr7yF%40msg.df7cb.de Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/987910502420b77eaf7c3e807f6b0fc1cffced29 Modified Files -------------- src/bin/scripts/vacuumdb.c | 5 ----- 1 file changed, 5 deletions(-)