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-24T11:43:47Z
Lists: pgsql-hackers
On Tue, 24 Mar 2026 at 10:57, Yugo Nagata <nagata@sraoss.co.jp> wrote:
>
> One concern is that CREATE STATISTICS does not allow creating extended
> statistics on a single colmun. If we try this, it raises the following error:
>
>  ERROR:  extended statistics require at least 2 columns
>
> Therefore, if we take this approach, we would need to add an exception
> to this rule for virtual columns.

I think that would be fine. It makes sense because a virtual column
expands to an expression, and we already allow CREATE STATISTICS on a
single expression.

Regards,
Dean



Commits

  1. Add support for extended statistics on virtual generated columns.