Re: FOR PORTION OF does not recompute GENERATED STORED columns that depend on the range column

Paul A Jungwirth <pj@illuminatedcomputing.com>

From: Paul A Jungwirth <pj@illuminatedcomputing.com>
To: jian he <jian.universality@gmail.com>
Cc: Chao Li <li.evan.chao@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-05-12T19:26:01Z
Lists: pgsql-hackers
On Mon, May 11, 2026 at 5:03 AM jian he <jian.universality@gmail.com> wrote:
>
> > > 2. I doubt if we need to switch to estate->es_query_cxt. Because ExecGetUpdatedCols() is called by ExecGetAllUpdatedCols(), and its header comment says the function runs in per-tuple memory context:
> > > ```
>
> Switching to estate->es_query_cxt can actually save some cycles.
>
> See ExecGetExtraUpdatedCols->ExecInitGenerated
>     /*
>      * Make sure these data structures are built in the per-query memory
>      * context so they'll survive throughout the query.
>      */
>     oldContext = MemoryContextSwitchTo(estate->es_query_cxt);

I agree that seems nice, but it doesn't seem correct if we sometimes
change the context and sometimes not (from execute_attr_map_cols).

Yours,

-- 
Paul              ~{:-)
pj@illuminatedcomputing.com