Re: EXPLAIN with anonymous DO block? - Mailing list pgsql-general

From David G. Johnston
Subject Re: EXPLAIN with anonymous DO block?
Date
Msg-id CAKFQuwayiLqaAHHoL5xLgNgMcNRtB+Ymh8MeXj8tRjLMQLTS_Q@mail.gmail.com
Whole thread Raw
In response to Re: EXPLAIN with anonymous DO block?  (Michael Lewis <mlewis@entrata.com>)
List pgsql-general
On Thu, Jul 1, 2021 at 9:22 AM Michael Lewis <mlewis@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.

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: EXPLAIN with anonymous DO block?
Next
From: Pavel Luzanov
Date:
Subject: Re: EXPLAIN with anonymous DO block?