Ron <ronljohnso...@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


Reply via email to