0001-Improve-autovacuum-doc-on-partitioned-tables.V3.patch

text/x-patch

Filename: 0001-Improve-autovacuum-doc-on-partitioned-tables.V3.patch
Type: text/x-patch
Part: 0
Message: Re: document the need to analyze partitioned tables

Patch

Format: format-patch
Series: patch 0001
Subject: Improve autovacuum doc on partitioned tables
File+
doc/src/sgml/maintenance.sgml 12 4
From 33ef30888b5f5b57c776a1bd00065e0c94daccdb Mon Sep 17 00:00:00 2001
From: Laurenz Albe <laurenz.albe@cybertec.at>
Date: Wed, 6 Sep 2023 05:43:30 +0200
Subject: [PATCH] Improve autovacuum doc on partitioned tables

The documentation mentioned that autovacuum doesn't process
partitioned tables, but it was unclear about the impact.
The old wording could be interpreted to mean that there are
problems with dead tuple cleanup on partitioned tables.
Clarify that the only potential problem is autoanalyze, and
that statistics for the partitions will be gathered.

Author: Laurenz Albe
Reviewed-by: Nathan Bossart, Justin Pryzby
Discussion: https://postgr.es/m/1fd81ddc7710a154834030133c6fea41e55c8efb.camel%40cybertec.at
---
 doc/src/sgml/maintenance.sgml | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 9cf9d030a8..10b1f211e8 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -861,10 +861,18 @@ analyze threshold = analyze base threshold + analyze scale factor * number of tu
    </para>
 
    <para>
-    Partitioned tables are not processed by autovacuum.  Statistics
-    should be collected by running a manual <command>ANALYZE</command> when it is
-    first populated, and again whenever the distribution of data in its
-    partitions changes significantly.
+    Partitioned tables do not directly store tuples and consequently do not
+    require autovacuum to perform any <command>VACUUM</command> operations.
+    Autovacuum performs a <command>VACUUM</command> on the partitioned
+    table's partitions the same as it does with other tables.  While that
+    works fine, the fact that autovacuum doesn't process partitioned tables
+    also means that it doesn't run <command>ANALYZE</command> on them, and this
+    can be problematic, as there are various places in the query planner that
+    attempt to make use of table statistics for partitioned tables when
+    partitioned tables are queried.  For now, you can work around this problem
+    by running a manual <command>ANALYZE</command> command on the partitioned
+    table when the partitioned table is first populated, and again whenever
+    the distribution of data in its partitions changes significantly.
    </para>
 
    <para>
-- 
2.41.0