From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Make SQLFunctionCache long-lived again. |
Date: | 2025-04-17 16:57:47 |
Message-ID: | E1u5SYd-000Vjt-1m@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Make SQLFunctionCache long-lived again.
At this point, the only data structures we allocate directly in
fcontext are the SQLFunctionCache struct itself, the ParamListInfo
struct, and the execution_state array, all of which are small and
perfectly capable of being re-used across executions of the same
FmgrInfo. Hence, let's give them the same lifespan as the FmgrInfo.
This step gets rid of the separate SQLFunctionLink struct and makes
fn_extra point to SQLFunctionCache again. We also get rid of the
separate fcontext memory context and allocate these items directly
in fn_mcxt.
For notational simplicity, SQLFunctionCache still has an fcontext
field, but it's just a copy of fn_mcxt.
The motivation for this is to allow these structures to live as
long as the FmgrInfo and be re-used across calls, restoring the
original design without its propensity for memory leaks. This
gets rid of some per-call overhead that we added in 0dca5d68d.
We also make an effort to re-use the JunkFilter and result slot.
Those might need to change if the function definition changes,
so we compromise by rebuilding them if the cached plan changes.
This also moves the tuplestore into fn_mcxt so that it can be
re-used across calls, again undoing a change made in 0dca5d68d.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/0313c5dc627a1407344617fa8dd84ce1374ec915
Modified Files
--------------
src/backend/executor/functions.c | 260 ++++++++++++++++-----------------------
1 file changed, 105 insertions(+), 155 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-04-17 17:02:05 | Re: pgsql: Make SQLFunctionCache long-lived again. |
Previous Message | Robert Haas | 2025-04-17 14:42:45 | Re: pgsql: Add function to get memory context stats for processes |