Re: analyze-in-stages post upgrade questions

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: "Zechman, Derek S" <Derek(dot)S(dot)Zechman(at)snapon(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: analyze-in-stages post upgrade questions
Date: 2025-06-28 05:25:30
Message-ID: f2ebeef82fddaf8a8152383f8ff62e75f20aac3c.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2025-06-28 at 01:23 +0000, Zechman, Derek S wrote:
> > Well, that wouldn't explain why it doesn't work on partitioned tables.
> > I am under the impression that it should.
> >
> > Derek, can cou share the pg_stats entries for the partitioned table?
>
> There are no entries in pg_stats for the parent table until after I manually run an analyze on it – Example below

You are right. I looked at the code, and "vacuumdb" does not process
partitiond tables, even if --analyze-only is specified. I find that
surprising, aince the SQL command ANALYZE (without a table name) will
also collect statistics for partitioned tables.

I think that it would be a good idea to change that behavior.
In particular, it makes a lot of sense to collect statistics for
partitioned tables after a "pg_upgrade".

Attached is a patch to make "vacuumdb --analyze-only" consider
partitioned tables as well.

Yours,
Laurenz Albe

Attachment Content-Type Size
v1-0001-Make-vacuumdb-Z-process-partitioned-tables.patch text/x-patch 3.0 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter J. Holzer 2025-06-28 13:59:23 Re: password rules
Previous Message Zechman, Derek S 2025-06-28 01:23:59 RE: analyze-in-stages post upgrade questions