Re: Autovacuum on partitioned table

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: yuzuko <yuzukohosoya(at)gmail(dot)com>
Cc: Masahiko Sawada <masahiko(dot)sawada(at)2ndquadrant(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Greg Stark <stark(at)mit(dot)edu>
Subject: Re: Autovacuum on partitioned table
Date: 2020-02-20 09:29:37
Message-ID: CA+HiwqG52Wy_Xds6X4UdbwK93S4FCD8Y0qWKN0V=NSyD=_Kk3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Feb 20, 2020 at 5:32 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> On Thu, Feb 20, 2020 at 4:50 PM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> > * I may be missing something, but why doesn't do_autovacuum() fetch a
> > partitioned table's entry from pgstat instead of fetching that for
> > individual children and adding? That is, why do we need to do the
> > following:
> >
> > + /*
> > + * If the relation is a partitioned table, we check it
> > using reltuples
> > + * added up childrens' and changes_since_analyze tracked
> > by stats collector.
>
> Oh, it's only adding up children's pg_class.reltuple, not pgstat
> stats. We need to do that because a partitioned table's
> pg_class.reltuples is always 0 and correctly so. Sorry for not
> reading the patch properly.

Having read the relevant diffs again, I think this could be done
without duplicating code too much. You seem to have added the same
logic in two places: do_autovacuum() and table_recheck_autovac().
More importantly, part of the logic of relation_needs_vacanalyze() is
duplicated in both of the aforementioned places, which I think is
unnecessary and undesirable if you consider maintainability. I think
we could just add the logic to compute reltuples for partitioned
tables at the beginning of relation_needs_vacanalyze() and be done. I
have attached a delta patch to show what I mean. Please check and
tell what you think.

Thanks,
Amit

Attachment Content-Type Size
v3_amit_delta.patch text/plain 9.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Takashi Menjo 2020-02-20 09:30:09 RE: [PoC] Non-volatile WAL buffer
Previous Message Peter Eisentraut 2020-02-20 09:15:41 Re: Add PostgreSQL home page to --help output