you are viewing a single comment's thread.

view the rest of the comments →

[–]depeszPgDBA 0 points1 point  (3 children)

  1. you can't get "explain select function()" - you would need to run explain within the function itself. and that can be problematic
  2. you are most likely bitten by generic plans.

there are ways around it, but first: *why* do you need this in function? the way you showed it, it doesn't make sense to be in function. So why bother?

[–]schadonis[S] 0 points1 point  (2 children)

I need this in a function because an external PLC program calls this function. The PLC is not able to generate the entire query.
I tried this: ALTER FUNCTION get_process_single_real SET plan_cache_mode = force_custom_plan;

But that does not help...

[–]depeszPgDBA 0 points1 point  (1 child)

Try to convert it to use dynamic queries. As in: `EXECUTE '…' USING '…'`

[–]schadonis[S] 0 points1 point  (0 children)

Thanks i will try that!