Re: document the need to analyze partitioned tables

Bruce Momjian <bruce@momjian.us>

From: Bruce Momjian <bruce@momjian.us>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, Laurenz Albe <laurenz.albe@cybertec.at>, Tomas Vondra <tomas.vondra@enterprisedb.com>, Robert Haas <robertmhaas@gmail.com>, Álvaro Herrera <alvherre@alvh.no-ip.org>, yuzuko <yuzukohosoya@gmail.com>, pgsql-hackers@postgresql.org
Date: 2023-01-17T21:16:20Z
Lists: pgsql-hackers
On Tue, Jan 17, 2023 at 03:00:50PM -0600, Justin Pryzby wrote:
> On Tue, Jan 17, 2023 at 03:53:24PM -0500, Bruce Momjian wrote:
> > On Thu, Jan 12, 2023 at 03:27:47PM -0800, Nathan Bossart wrote:
> > > Here is my take on the wording:
> > > 
> > > 	Since all the data for a partitioned table is stored in its partitions,
> > > 	autovacuum does not process partitioned tables.  Instead, autovacuum
> > > 	processes the individual partitions that are regular tables.  This
> > > 	means that autovacuum only gathers statistics for the regular tables
> > > 	that serve as partitions and not for the partitioned tables.  Since
> > > 	queries may rely on a partitioned table's statistics, you should
> > > 	collect statistics via the ANALYZE command when it is first populated,
> > > 	and again whenever the distribution of data in its partitions changes
> > > 	significantly.
> > 
> > Uh, what about autovacuum's handling of partitioned tables?  This makes
> > it sound like it ignores them because it talks about manual ANALYZE.
> 
> If we're referring to the *partitioned* table, then it does ignore them.
> See:
> 
> |commit 6f8127b7390119c21479f5ce495b7d2168930e82
> |Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
> |Date:   Mon Aug 16 17:27:52 2021 -0400
> |
> |    Revert analyze support for partitioned tables

Yes, I see that patch was trying to combine the statistics of individual
partitions into a partitioned table summary.

> Maybe (all?) the clarification the docs need is to say:
> "Partitioned tables are not *themselves* processed by autovacuum."

Yes, I think the lack of autovacuum needs to be specifically mentioned
since most people assume autovacuum handles _all_ statistics updating.

Can someone summarize how bad it is we have no statistics on partitioned
tables?  It sounds bad to me. 

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

Embrace your flaws.  They make you human, rather than perfect,
which you will never be.



Commits

  1. doc: Fix typo in ANALYZE documentation

  2. Document autoanalyze limitations for partitioned tables

  3. Revert analyze support for partitioned tables

  4. Describe (auto-)analyze behavior for partitioned tables