| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: vacuumdb: Use ANALYZE ONLY for partitioned tables |
| Date: | 2026-08-13 05:25:47 |
| Message-ID: | E1wuNwo-00000000Mev-04B5@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
vacuumdb: Use ANALYZE ONLY for partitioned tables
When vacuumdb --analyze-only or --analyze-in-stages enumerates
tables itself, it can select both a partitioned table and its
partitions as separate work items. Previously, it generated plain
ANALYZE for the partitioned table, which recursively analyzed its
partitions as well.
This caused duplicate work when the partitions were already selected by
vacuumdb. With --analyze-in-stages, the redundant work could be
repeated at every stage.
Fix this by generating ANALYZE ONLY for automatically selected
partitioned tables when connected to servers that support it. This
updates inherited statistics for the partitioned table while leaving
per-partition statistics to the separately selected partition entries.
For older servers that do not support ANALYZE ONLY, vacuumdb falls back
to the previous plain ANALYZE command.
This also applies when partitioned tables are selected by schema
filters. In that case, partitions matching the filters are analyzed as
separate targets, while per-partition statistics for partitions outside
the filters are not updated via the partitioned parent.
This commit does not change the behavior for partitioned tables
specified explicitly with --table, i.e., in that case, vacuumdb
continues to generate plain ANALYZE, recursively analyzing the specified
partitioned table and its partitions.
Suggested-by: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Discussion: https://postgr.es/m/aKZ7lMYGnnIo35c0@pryzbyj2023
Backpatch-through: 19
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/9e725e77a5d8356a2237a15025b57d75b08e87e4
Modified Files
--------------
src/bin/scripts/t/100_vacuumdb.pl | 8 ++-
src/bin/scripts/vacuuming.c | 120 +++++++++++++++++++++++++-------------
src/tools/pgindent/typedefs.list | 2 +
3 files changed, 88 insertions(+), 42 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2026-08-13 11:22:02 | pgsql: pgcrypto: remove unused field mdc_checked from PGP_Context |
| Previous Message | Fujii Masao | 2026-08-13 05:25:30 | pgsql: vacuumdb: Use ANALYZE ONLY for partitioned tables |