Re: pgsql: autovacuum: handle analyze for partitioned tables

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Zhihong Yu <zyu(at)yugabyte(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Yuzuko <yuzukohosoya(at)gmail(dot)com>
Subject: Re: pgsql: autovacuum: handle analyze for partitioned tables
Date: 2021-04-09 21:31:55
Message-ID: 20210409213155.GA23912@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2021-Apr-09, Robert Haas wrote:

> Does this need to worry about new partitions getting attached to a
> partitioned table, or old ones getting detached? (Maybe it does
> already, not sure.)

Good question. It does not.

I suppose you could just let that happen automatically -- I mean, next
time the partitioned table is analyzed, it'll scan all attached
partitions. But if no tuples are modified afterwards in existing
partitions (a common scenario), and the newly attached partition
contains lots of rows, then only future rows in the newly attached
partition would affect the stats of the partitioned table, and it could
be a long time before that causes an analyze on the partitioned table to
occur.

Maybe a way to attack this is to send a the "anl_ancestors" message to
the collector on attach and detach, adding a new flag ("is
attach/detach"), which indicates to add not only "changes_since_analyze
- changes_since_analyze_reported", but also "n_live_tuples".

--
Álvaro Herrera 39°49'30"S 73°17'W
Essentially, you're proposing Kevlar shoes as a solution for the problem
that you want to walk around carrying a loaded gun aimed at your foot.
(Tom Lane)

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2021-04-09 21:37:14 pgsql: doc: Fix man page whitespace issues
Previous Message Alvaro Herrera 2021-04-09 21:15:29 pgsql: Suppress length of Notice/Error msgs in PQtrace regress mode

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2021-04-09 21:45:08 Re: pgsql: autovacuum: handle analyze for partitioned tables
Previous Message Alvaro Herrera 2021-04-09 21:16:11 Re: libpq debug log