[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.
Born in Arizona, moved to Babylonia.