Thread: implement EXPLAIN EXECUTE

implement EXPLAIN EXECUTE

From
Neil Conway
Date:
This patch implements EXPLAIN EXECUTE, including documentation updates.
I also refactored a bunch of the code in prepare.c, and made a few
cleanups to the EXPLAIN documentation.

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC



Attachment

Re: implement EXPLAIN EXECUTE

From
Tom Lane
Date:
Neil Conway <neilc@samurai.com> writes:
> This patch implements EXPLAIN EXECUTE, including documentation updates.

This seems like quite a messy way to do things.  Why not just make the
grammar

ExplainStmt:
            EXPLAIN opt_analyze opt_verbose OptimizableStmt
          | EXPLAIN opt_analyze opt_verbose ExecuteStmt

where ExplainStmt.query can point to either an optimizable statement
or an ExecuteStmt.

Then you'd not need one single change (I think) in parsenodes.h nor
analyze.c, nor need to expose subroutines of explain.c to outside.
Instead, prepare.c would have to expose a function to fetch the plan
tree for a prepared query, but that seems a reasonable thing to do.

            regards, tom lane

Re: implement EXPLAIN EXECUTE

From
Neil Conway
Date:
On Sun, 2003-01-12 at 14:31, Tom Lane wrote:
> ExplainStmt:
>             EXPLAIN opt_analyze opt_verbose OptimizableStmt
>           | EXPLAIN opt_analyze opt_verbose ExecuteStmt

> Then you'd not need one single change (I think) in parsenodes.h nor
> analyze.c, nor need to expose subroutines of explain.c to outside.
> Instead, prepare.c would have to expose a function to fetch the plan
> tree for a prepared query, but that seems a reasonable thing to do.

I thought about that (and even partially implemented it), but I decided
against it: when you take into account the need to accept & evaluate
parameters (or else EXPLAIN ANALYZE isn't much use on a prepared query),
you need to modify analyze.c anyway, and I wasn't that comfortable
teaching explain.c a lot about the inner workings of prepare.c

I think my implementation isn't too messy, anyway -- the majority of the
changes are just refactoring the existing code into smaller functions,
so that it can be reused more easily (which is probably a good idea
anyway, IMHO).

However, if you'd prefer I can redo the implementation as you suggested.
Let me know...

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC




Re: implement EXPLAIN EXECUTE

From
Tom Lane
Date:
Neil Conway <neilc@samurai.com> writes:
> I thought about that (and even partially implemented it), but I decided
> against it: when you take into account the need to accept & evaluate
> parameters (or else EXPLAIN ANALYZE isn't much use on a prepared query),
> you need to modify analyze.c anyway,

Why?  The handling of ExplainStmt presently recurses to transformStmt,
which is perfectly capable of handling an ExecuteStmt in the query
field.

            regards, tom lane