Re: Don't treat virtual generated columns as missing statistics in vacuumdb --missing-stats-only

From: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Don't treat virtual generated columns as missing statistics in vacuumdb --missing-stats-only
Date: 2025-08-20 04:30:12
Message-ID: 20250820133012.c3c013055f8409e4765a72e8@sraoss.co.jp
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 20 Aug 2025 12:49:14 +0900
Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:

> On Wed, Aug 20, 2025 at 10:42 AM Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:
> >
> > Hi,
> >
> > I found that "vacuumdb --missing-stats-only" always performs ANALYZE
> > on tables with a virtual generated column, since such columns currently
> > never have statistics. This seems like an obvious waste, so I've attached
> > a patch to fix it, ensuring that virtual generated columns are not
> > regarded as missing statistics.
>
> Thanks for the report and patch! This seems to be an oversight from
> the commit that added virtual generated columns.
>
> For the patch, shouldn't we also add a regression test for --missing-stats-only
> with generated columns, to prevent this issue from happening again?

Thank you for reviewing the patch and your suggestion.

I agree that we should add a test, since the behavior may change in the future
when statistics begin to be collected for virtual generated columns, and the test
will serve as a reminder when this behavior changes.

I've attached a updated patch including the test.

Regards,
Yugo Nagata

--
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>

Attachment Content-Type Size
v2-0001-Don-t-treat-virtual-generated-columns-as-missing-.patch text/x-diff 2.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2025-08-20 04:31:29 Re: analyze-in-stages post upgrade questions
Previous Message Naga Appani 2025-08-20 04:27:41 Re: [Proposal] Expose internal MultiXact member count function for efficient monitoring