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

Yugo Nagata <nagata@sraoss.co.jp>

From: Yugo Nagata <nagata@sraoss.co.jp>
To: Fujii Masao <masao.fujii@gmail.com>
Cc: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2025-08-20T04:53:38Z
Lists: pgsql-hackers

Attachments

On Wed, 20 Aug 2025 13:30:12 +0900
Yugo Nagata <nagata@sraoss.co.jp> wrote:

> On Wed, 20 Aug 2025 12:49:14 +0900
> Fujii Masao <masao.fujii@gmail.com> wrote:
> 
> > On Wed, Aug 20, 2025 at 10:42 AM Yugo Nagata <nagata@sraoss.co.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@sraoss.co.jp>

Commits

  1. vacuumdb: Fix --missing-stats-only with virtual generated columns.