Can a PL/pgSQL function contain a dynamic subquery?
I am writing a PL/pgSQL function. The function has input parameters which specify (indirectly), which tables to read filtering informa开发者_如何学Ction from.
The function embeds business logic which allows it to select data from different tables based on the input arguments. The function dynamically builds a subquery which returns filtering data which is then used to run the main query.
My questions are:
Is it 'legal' to use a dynamic subquery in a PL/pgSQL function. I cant see why not - but this question is related to the next one.
AFAIK, PL/pgSQL are cached or precompiled by the query engine. How does having a function that generates dynamic subqueries impact the work of the query engine?
"38.5.4. Executing Dynamic Commands"
精彩评论