public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: Renan Alves Fonseca <[email protected]>
Cc: David Rowley <[email protected]>
Cc: Evgeny Morozov <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Querying one partition in a function takes locks on all partitions
Date: Mon, 31 Mar 2025 13:58:33 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <01020195b987abd3-a008b77d-8c63-4931-80a4-be36a351c8b2-000000@eu-west-1.amazonses.com>
<CAN_p2Qi_zie4aZqMcYuT-Y5CxyvUJ+nBAomQNJSPbBjrCPEXJw@mail.gmail.com>
<01020195dd9e8337-c912f36d-54ef-4d3c-a00d-5e697b308d33-000000@eu-west-1.amazonses.com>
<CAN_p2QghEHKeyTvb6Gc8F3y6wNm+dJXaCdrAnrV7TEq15Oh-pg@mail.gmail.com>
<CAApHDvp3EDrVhGjmb21bceJ5-Y7iXKOn2UGG3-ngp_9ob_mpLw@mail.gmail.com>
<CAN_p2QjXkBzyx55QAEGLfvWF0_UdusvxNmTykq_6jQsaaqjwTw@mail.gmail.com>
<[email protected]>
Laurenz Albe <[email protected]> writes:
> On Mon, 2025-03-31 at 18:41 +0200, Renan Alves Fonseca wrote:
>> I would add another Note below like:
>> "Except when inlined, an SQL function is always executed with a
>> generic plan. This behavior may not be desired in some situations, and
>> it will be fixed in future versions."
> But that is not true, as far as I can tell: just like any other prepared
> statement, it may keep using custom plans.
No, it is a generic plan in the current code. See functions.c's
init_execution_state, which calls pg_plan_query without passing
any boundParams. That's kind of necessary in the current scheme
of things, because the SQL function holds onto the plan for the
duration of the current query and re-uses the plan during subsequent
calls with (possibly) different parameter values. So it's sort of
a poor man's plan cache, but implemented in about the stupidest
way possible. Jacking that up and rolling the plancache.c
infrastructure underneath has been on my to-do list for years.
regards, tom lane
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Querying one partition in a function takes locks on all partitions
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox