0

I've been using postgresql's explain syntax to analyze queries. However, I tried to run it against a custom function, sproc, but it does not analyze it. Is there a way to use explain against a function? If not natively is there a way to programmatically export the function body and have the query analyzer fun against that?

1

1 Answer 1

1

Not really, and given PostgreSQL's pluggable procedural languages it's unlikely to happen in a general way. In any case, EXPLAIN for functions that are more than just a query with parameters is perhaps not well-defined as a concept.

A typical work-around is to extract the query-part and do PREPARE foo(...) ... SELECT followed by EXPLAIN EXECUTE foo(...). This lets you see the plan for a simple parameterised select.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.