pgsql: vacuumdb: Make vacuumdb --analyze-only process partitioned table

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: vacuumdb: Make vacuumdb --analyze-only process partitioned table
Date: 2025-08-20 04:17:25
Message-ID: E1uoaGL-000kp5-13@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <Derek(dot)S(dot)Zechman(at)snapon(dot)com>
Author: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Co-authored-by: Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/CO1PR04MB8281387B9AD9DE30976966BBC045A%40CO1PR04MB8281.namprd04.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6429e5b771dbb98aa56441677b79cdb58f6e1675

Modified Files
--------------
doc/src/sgml/ref/vacuumdb.sgml | 9 +++++++++
src/bin/scripts/t/100_vacuumdb.pl | 11 +++++++++++
src/bin/scripts/vacuumdb.c | 24 ++++++++++++++++++++----
3 files changed, 40 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-08-20 05:57:20 Re: pgsql: Move SQL-callable code related to multixacts into its own file
Previous Message Nathan Bossart 2025-08-19 21:49:08 pgsql: Fix comment for MAX_SIMUL_LWLOCKS.