Re: EXPLAIN with anonymous DO block?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: Ron <ronljohnsonjr(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: EXPLAIN with anonymous DO block?
Date: 2021-07-01 16:28:54
Message-ID: CAKFQuwayiLqaAHHoL5xLgNgMcNRtB+Ymh8MeXj8tRjLMQLTS_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 1, 2021 at 9:22 AM Michael Lewis <mlewis(at)entrata(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Luzanov 2021-07-01 16:48:11 Re: EXPLAIN with anonymous DO block?
Previous Message Tom Lane 2021-07-01 16:27:35 Re: EXPLAIN with anonymous DO block?