vacuumdb: Make vacuumdb --analyze-only process partitioned tables.
authorFujii Masao <[email protected]>
Wed, 20 Aug 2025 04:16:06 +0000 (13:16 +0900)
committerFujii Masao <[email protected]>
Wed, 20 Aug 2025 04:16:06 +0000 (13:16 +0900)
commit6429e5b771dbb98aa56441677b79cdb58f6e1675
tree16fe635100941c9b622d1c18b7ddfd303c0a4c25
parent3eec0e65331e4a38d0c8b3ac251ea3885452fd71
vacuumdb: Make vacuumdb --analyze-only process partitioned tables.

vacuumdb should follow the behavior of the underlying VACUUM and ANALYZE
commands. When --analyze-only is used, it ought to analyze regular tables,
materialized views, and partitioned tables, just as ANALYZE (with no explicit
target tables) does. Otherwise, it should only process regular tables and
materialized views, since VACUUM skips partitioned tables when no targets
are given.

Previously, vacuumdb --analyze-only skipped partitioned tables. This was
inconsistent, and also inconvenient after pg_upgrade, where --analyze-only
is typically used to gather missing statistics.

This commit fixes the behavior so that vacuumdb --analyze-only also processes
partitioned tables. As a result, both vacuumdb --analyze-only and
ANALYZE (with no explicit targets) now analyze regular tables,
partitioned tables, and materialized views, but not foreign tables.

Because this is a nontrivial behavior change, it is applied only to master.

Reported-by: Zechman, Derek S <[email protected]>
Author: Laurenz Albe <[email protected]>
Co-authored-by: Mircea Cadariu <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: https://postgr.es/m/CO1PR04MB8281387B9AD9DE30976966BBC045A%40CO1PR04MB8281.namprd04.prod.outlook.com
doc/src/sgml/ref/vacuumdb.sgml
src/bin/scripts/t/100_vacuumdb.pl
src/bin/scripts/vacuumdb.c