Re: Allow to collect statistics on virtual generated columns - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Allow to collect statistics on virtual generated columns
Date
Msg-id CAEZATCVtSyr1eOmHT=8B4i=RqHHM6_vbhLJhJorU+F89MMpA-A@mail.gmail.com
Whole thread
In response to Re: Allow to collect statistics on virtual generated columns  (Yugo Nagata <nagata@sraoss.co.jp>)
Responses Re: Allow to collect statistics on virtual generated columns
List pgsql-hackers
On Tue, 31 Mar 2026 at 15:35, Yugo Nagata <nagata@sraoss.co.jp> wrote:
>
> Thank you for updating the patch. I am fine with that.
>
> One concern is that users might interpret "stored" as referring to
> "stored generated columns", rather than including regular columns,

Yeah, possibly. I changed "stored" to "non-virtual", which should
reduce the chances of that particular confusion.

> Also, the meaning of "automatically" might be a bit unclear, so we
> could clarify it by adding "without defining extended statistics."
>
>       Defining extended statistics on a single <emphasis>stored</emphasis>
>       column is not supported or necessary, because statistics are built
>       automatically on such columns without defining extended statistics.

OK, pushed that way.

I also noticed that a few places in CreateStatistics() could use the
variable "numcols" instead of "list_length(stmt->exprs)", so I changed
that.

I decided to include the change to the error message discussed in [1],
since there seemed to be a consensus there, except that I think it
also needs to make it clear that it refers only to non-virtual
columns.

In addition, there was another nearby error message which was no
longer quite right for statistics on virtual generated columns, and I
changed the order of checks, since that allowed the "if" statements to
be simplified a bit.

Regards,
Dean

[1] https://www.postgresql.org/message-id/20260324203430.411331c59ca462457ec0aa8b%40sraoss.co.jp



pgsql-hackers by date:

Previous
From: "Greg Burd"
Date:
Subject: Re: clang bug affecting greenfly
Next
From: Dean Rasheed
Date:
Subject: Re: Adjust error message for CREATE STATISTICS to account for expressions