Re: EXPLAIN with anonymous DO block?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: EXPLAIN with anonymous DO block?
Дата
Msg-id 699960.1625156855@sss.pgh.pa.us
обсуждение исходный текст
Ответ на EXPLAIN with anonymous DO block?  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: EXPLAIN with anonymous DO block?  (Pavel Luzanov <p.luzanov@postgrespro.ru>)
Список pgsql-general
Ron <ronljohnsonjr@gmail.com> writes:
> There's a query inside a DO block which -- because it's parameterized -- I'd
> rather analyze while it's in the FOR loop of a DO block, instead of pulling
> it out and hard-coding the parameters.

> Is this possible?

No.

The thing to do to duplicate the behavior of a plpgsql query is
to set it up as a PREPAREd statement (with parameters for any
plpgsql variables it references) and use EXPLAIN EXECUTE.
This also works if you're curious about the behavior of a
query issued via PQexecParams or the like.

It's recommendable to repeat the EXPLAIN half a dozen times
to see if the plancache switches from a custom to a generic
plan.  (In recent PG releases, changing plan_cache_mode
is another way to check what happens.)

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Lewis
Дата:
Сообщение: Re: EXPLAIN with anonymous DO block?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: EXPLAIN with anonymous DO block?