pgsql: Add ONLY support for VACUUM and ANALYZE

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add ONLY support for VACUUM and ANALYZE
Date: 2024-09-24 06:04:21
Message-ID: E1ssyeq-000e41-ON@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add ONLY support for VACUUM and ANALYZE

Since autovacuum does not trigger an ANALYZE for partitioned tables,
users must perform these manually. However, performing a manual ANALYZE
on a partitioned table would always result in recursively analyzing each
partition and that could be undesirable as autovacuum takes care of that.
For partitioned tables that contain a large number of partitions, having
to analyze each partition could take an unreasonably long time, especially
so for tables with a large number of columns.

Here we allow the ONLY keyword to prefix the name of the table to allow
users to have ANALYZE skip processing partitions. This option can also
be used with VACUUM, but there is no work to do if VACUUM ONLY is used on
a partitioned table.

This commit also changes the behavior of VACUUM and ANALYZE for
inheritance parents. Previously inheritance child tables would not be
processed when operating on the parent. Now, by default we *do* operate
on the child tables. ONLY can be used to obtain the old behavior.
The release notes should note this as an incompatibility. The default
behavior has not changed for partitioned tables as these always
recursively processed the partitions.

Author: Michael Harris <harmic(at)gmail(dot)com>
Discussion: https://postgr.es/m/CADofcAWATx_haD=QkSxHbnTsAe6+e0Aw8Eh4H8cXyogGvn_kOg@mail.gmail.com
Discussion: https://postgr.es/m/CADofcAXVbD0yGp_EaC9chmzsOoSai3jcfBCnyva3j0RRdRvMVA@mail.gmail.com
Reviewed-by: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Reviewed-by: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
Reviewed-by: Atsushi Torikoshi <torikoshia(at)oss(dot)nttdata(dot)com>
Reviewed-by: jian he <jian(dot)universality(at)gmail(dot)com>
Reviewed-by: David Rowley <dgrowleyml(at)gmail(dot)com>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/62ddf7ee9a399e0b9624412fc482ed7365e38958

Modified Files
--------------
doc/src/sgml/ddl.sgml | 23 +++++----
doc/src/sgml/monitoring.sgml | 6 +--
doc/src/sgml/ref/analyze.sgml | 36 +++++++-------
doc/src/sgml/ref/vacuum.sgml | 11 +++--
src/backend/commands/vacuum.c | 39 ++++++++++-----
src/backend/parser/gram.y | 2 +-
src/test/regress/expected/vacuum.out | 92 ++++++++++++++++++++++++++++++++++++
src/test/regress/sql/vacuum.sql | 66 ++++++++++++++++++++++++++
8 files changed, 230 insertions(+), 45 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2024-09-24 13:42:59 Re: pgsql: Allow meson builds to run test_pg_dump test in installcheck mode
Previous Message Michael Paquier 2024-09-24 03:40:34 pgsql: Allow meson builds to run test_pg_dump test in installcheck mode