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 <[email protected]> Author: Fujii Masao <[email protected]> Reviewed-by: Daniel Gustafsson <[email protected]> Discussion: https://postgr.es/m/aKZ7lMYGnnIo35c0@pryzbyj2023 Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/72e6184cd5fe82620693a2aae9e34452d1984459 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(-)
