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:53:38
Message-ID: 20250820135338.cb5c1528de5b81bc753be379@sraoss.co.jp
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 20 Aug 2025 13:30:12 +0900
Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:

> 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.

The patch conflicted with the latest commit, so I rebased it.

Regards,
Yugo Nagata

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

Attachment Content-Type Size
v3-0001-Avoid-treating-virtual-generated-columns-as-missi.patch text/x-diff 2.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-08-20 05:03:10 Re: VM corruption on standby
Previous Message Fujii Masao 2025-08-20 04:31:29 Re: analyze-in-stages post upgrade questions