Re: Allow to collect statistics on virtual generated columns
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Yugo Nagata <nagata@sraoss.co.jp>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@postgresql.org
Date: 2026-03-29T10:42:47Z
Lists: pgsql-hackers
Attachments
- v12-0001-Add-support-for-extended-statistics-on-virtual-g.patch (text/x-patch) patch v12-0001
On Fri, 27 Mar 2026 at 07:44, Yugo Nagata <nagata@sraoss.co.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
Commits
-
Add support for extended statistics on virtual generated columns.
- f7f4052a4e95 19 (unreleased) landed