@@ -250,20 +250,38 @@ ANALYZE [ VERBOSE ] [ <replaceable class="parameter">table_and_columns</replacea
250
250
</para>
251
251
252
252
<para>
253
- If the table being analyzed has one or more children,
254
- <command>ANALYZE</command> will gather statistics twice: once on the
255
- rows of the parent table only, and a second time on the rows of the
256
- parent table with all of its children. This second set of statistics
257
- is needed when planning queries that traverse the entire inheritance
258
- tree. The autovacuum daemon, however, will only consider inserts or
259
- updates on the parent table itself when deciding whether to trigger an
260
- automatic analyze for that table. If that table is rarely inserted into
261
- or updated, the inheritance statistics will not be up to date unless you
262
- run <command>ANALYZE</command> manually.
253
+ If the table being analyzed is partitioned, <command>ANALYZE</command>
254
+ will gather statistics by sampling blocks randomly from its partitions;
255
+ in addition, it will recurse into each partition and update its statistics.
256
+ (However, in multi-level partitioning scenarios, each leaf partition
257
+ will only be analyzed once.)
258
+ By constrast, if the table being analyzed has inheritance children,
259
+ <command>ANALYZE</command> will gather statistics for it twice:
260
+ once on the rows of the parent table only, and a second time on the
261
+ rows of the parent table with all of its children. This second set of
262
+ statistics is needed when planning queries that traverse the entire
263
+ inheritance tree. The child tables themselves are not individually
264
+ analyzed in this case.
263
265
</para>
264
266
265
267
<para>
266
- If any of the child tables are foreign tables whose foreign data wrappers
268
+ The autovacuum daemon counts inserts, updates and deletes in the
269
+ partitions to determine if auto-analyze is needed. However, adding
270
+ or removing partitions does not affect autovacuum daemon decisions,
271
+ so triggering a manual <command>ANALYZE</command> is recommended
272
+ when this occurs.
273
+ </para>
274
+
275
+ <para>
276
+ Tuples changed in inheritance children do not count towards analyze
277
+ on the parent table. If the parent table is empty or rarely modified,
278
+ it may never be processed by autovacuum. It's necessary to
279
+ periodically run a manual <command>ANALYZE</command> to keep the
280
+ statistics of the table hierarchy up to date.
281
+ </para>
282
+
283
+ <para>
284
+ If any of the child tables or partitions are foreign tables whose foreign data wrappers
267
285
do not support <command>ANALYZE</command>, those child tables are ignored while
268
286
gathering inheritance statistics.
269
287
</para>
0 commit comments