Autovacuum (analyze) on partitioned tables for ATTACH/DETACH/DROP commands

Started by yuzukoover 5 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t44420
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 04:48 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t44420_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t44420_1 && git checkout t44420_1

Patchset v1 (message #1) is on t44420_1

Jump to latest
#1yuzuko
yuzukohosoya@gmail.com

Hello,

While discussing auto analyze on partitioned tables, we recognized that
auto analyze should run on partitioned tables when ATTACH, DETACH
and DROP commands are executed [1]/messages/by-id/ce5c3f04-fc17-7139-fffc-037f2c981bec@enterprisedb.com -- Best regards, Yuzuko Hosoya NTT Open Source Software Center. Partitioned tables are checked
whether they need auto analyze according to their
changes_since_analyze (total number of inserts/updates/deletes on
partitions), but above DDL operations are not counted for now.

To support ATTACH, DETACH and DROP commands, I proposed
the idea as follows:
* I made new configuration parameters,
autovacuum_analyze_attach_partition,
autovacuum_analyze_detach_partition and
autovacuum_analyze_drop_partition to enable/disable this feature.
* When a partition is attached/detached/dropped, pgstat_report_anl_ancestors()
is called and checks the above configurations. If ture, the number of
livetuples of the partition is counted in its ancestor's changed tuples
in pgstat_recv_anl_ancestors.

Attach the v1 patch. What do you think?

[1]: /messages/by-id/ce5c3f04-fc17-7139-fffc-037f2c981bec@enterprisedb.com -- Best regards, Yuzuko Hosoya NTT Open Source Software Center
--
Best regards,
Yuzuko Hosoya
NTT Open Source Software Center

Attachments:

t44420_1
v1_autovacuum_for_attach_detach_drop_commands.patchapplication/octet-stream; name=v1_autovacuum_for_attach_detach_drop_commands.patchDownload+257-18
#2Daniel Gustafsson
daniel@yesql.se
In reply to: yuzuko (#1)
Re: Autovacuum (analyze) on partitioned tables for ATTACH/DETACH/DROP commands

On 21 Jun 2021, at 10:21, yuzuko <yuzukohosoya@gmail.com> wrote:

Attach the v1 patch. What do you think?

This patch no longer applies to HEAD, can you please submit a rebased version
for the commitfest?

--
Daniel Gustafsson https://vmware.com/

#3Michael Paquier
michael@paquier.xyz
In reply to: Daniel Gustafsson (#2)
Re: Autovacuum (analyze) on partitioned tables for ATTACH/DETACH/DROP commands

On Wed, Sep 01, 2021 at 11:11:08AM +0200, Daniel Gustafsson wrote:

This patch no longer applies to HEAD, can you please submit a rebased version
for the commitfest?

Four weeks later, nothing has happened. So I have marked the patch as
RwF.
--
Michael