Re: right way of using case-expressions in plpgsql functions - Mailing list pgsql-general

From Victor Dobrovolsky
Subject Re: right way of using case-expressions in plpgsql functions
Date
Msg-id CAJFsatNMKPztXwmdwOdkdzrAsUvU78bakE4cwS7D2n92bE6U3A@mail.gmail.com
Whole thread Raw
In response to Re: right way of using case-expressions in plpgsql functions  (Ron <ronljohnsonjr@gmail.com>)
List pgsql-general
Thank you. I'll take it.

пн, 16 окт. 2023 г. в 00:20, Ron <ronljohnsonjr@gmail.com>:
On 10/15/23 11:19, Victor Dobrovolsky wrote:
[snip]
The documentation states that after some executions of such functions the plan should become generic.
What is a generic plan for such a case and how would it work?

It's highly dependent on the query

When I see this happen (after we notice that a procedure starts taking a long time), the query planner flips from a custom plan to a generic plan after about the fifth execution in a session of a function/procedure.

This will make it calculate the plan every time:
set plan_cache_mode = force_custom_plan;

--
Born in Arizona, moved to Babylonia.

pgsql-general by date:

Previous
From: Victor Dobrovolsky
Date:
Subject: Re: right way of using case-expressions in plpgsql functions
Next
From: Thiemo Kellner
Date:
Subject: Purely declarative FKs