Re: Allow to collect statistics on virtual generated columns

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Allow to collect statistics on virtual generated columns
Date: 2026-03-29 10:42:47
Message-ID: CAEZATCXMxaMP68A9HjC0NtMtzCfVyvDiYjH-zOVLcLj5B1pFgg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 27 Mar 2026 at 07:44, Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:
>
> Sorry, I forgot to update the test along with the previous fix.
> I've attached a revised patch including the updated test.
>

I did some more testing of this (things like dependencies, permission
checks in the selectivity functions, and dump/restore), and everything
worked as expected.

The code changes look good. It's nice that it worked out to be quite a
small, neat patch, and I think it's more-or-less ready for commit,
though I did find a few minor issues:

I noted that ALTER TABLE ... SET STATISTICS doesn't work for a virtual
generated column. I think that's OK, because we don't have statistics
by default on such columns, and ALTER STATISTICS ... SET STATISTICS
can be used instead if extended statistics are added. We could perhaps
relax that restriction in a future patch, but I don't think it's
necessary right now. However, I do think it's worth documenting the
limitation, so I'm attaching an update doing that.

In create_statistics.sgml, there were a number of other things that
needed updating. Please check the attached updates.

I found another comment in CreateStatistics() that needed updating,
and some indentation needed fixing.

In the regression tests, I reduced the size of the new test table --
given the recent discussion around how long the tests take to run, we
don't want to make that worse.

I also added a couple more simple tests, just to confirm that
univariate statistics work correctly, and also fixed the test
statistics "virtual_gen_stats_single_without_less_than", which was
built on the wrong column.

If you're happy with those changes, I'll push this.

Regards,
Dean

Attachment Content-Type Size
v12-0001-Add-support-for-extended-statistics-on-virtual-g.patch text/x-patch 26.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Evgeny Voropaev 2026-03-29 11:47:09 Re: Compress prune/freeze records with Delta Frame of Reference algorithm
Previous Message Xianbin Zhu 2026-03-29 07:05:11 [PATCH v1] psql: complete ALTER ROLE ... IN DATABASE ... RESET