0

I have a question regarding the execution of a Python UDF. Let's suppose I have a UDF named testUDF(...) and I apply it to table "testtable". When I run the query SELECT testUDF(...) from testtable, I get the correct result (I omitted the params of the UDF on purpose).

However, when I want to check the query plan for this query, the UDF is not included in there. I used

 EXPLAIN ANALYZE 
 SELECT testUDF(...) 
 from testtable

and

 EXPLAIN 
 SELECT testUDF(...) 
 from testtable. 

In both cases, the output only shows a seq. scan but the UDF is not mentioned anywhere. For more complex queries, I am interested in how to see at which position of the query plan the UDF is executed. How is this possible? Many thanks in advance for your help!

KSV97
  • 3
  • 2
  • I did follow the steps described here but the output was similar to the normal EXPLAIN. The UDF did not show up as part of the query plan.https://dba.stackexchange.com/questions/23355/postgres-query-plan-of-a-function-invocation-written-in-plpgsql – KSV97 Nov 17 '22 at 04:42
  • 2
    You need explain (verbose) (or explain (analyze, verbose) to see that the function is called. That would include e.g. Output: testudf(...) but you will never see the execution plan for statements inside the function if that is what you are hoping for. –  Nov 17 '22 at 05:57
  • @a_horse_with_no_name That qualifies as an answer. – Laurenz Albe Nov 17 '22 at 07:09

0 Answers0