On Thu, Jul 1, 2021 at 9:22 AM Michael Lewis <mle...@entrata.com> wrote:

> It sounds like you are wanting to run 'explain analyze [query]' inside a
> loop inside a DO block. That isn't possible as far as I know, but
> auto_explain and log_nested_statements should be able to let you profile
> the whole thing and perhaps you can pick out the part you want from the
> logs.
>

I believe it can be done technically, though basically the function will
need to be re-written for the purpose. It isn't as simple as adding an
explain somewhere since the output of explain is a result set.  But as you
are already using pl/pgsql  then your parameters can just be done up as
variables instead and that query should be able to be explained.

David J.

Reply via email to