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

 SELECT testUDF(...) 
 from testtable


 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!

  • 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.dba.stackexchange.com/questions/23355/…
    – KSV97
    Nov 17, 2022 at 4: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.
    – user1822
    Nov 17, 2022 at 5:57
  • @a_horse_with_no_name That qualifies as an answer. Nov 17, 2022 at 7:09


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.