Re: Query Plan Columns

Dimitri Fontaine <dimitri@2ndquadrant.fr>

From: Dimitri Fontaine <dimitri@2ndQuadrant.fr>
To: "David E. Wheeler" <david@kineticode.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2010-11-09T08:12:06Z
Lists: pgsql-hackers
"David E. Wheeler" <david@kineticode.com> writes:
> I'm wondering if there's any reason why we couldn't have EXPLAIN do something like this itself in core:
>
>     EXPLAIN (format table) SELECT * FROM bar;

+1 from me here, as it happens "parsing" a table-like resultset is
already implemented everywhere :)

I'd add another +1 if it were easily usable as a "normal" relation (or
SRF) from inside a query, e.g. in a WITH table expression.

WITH plan AS (
  EXPLAIN (format table) SELECT * FROM bar
)
SELECT some_plan_analysis_query_here;

Or even:

WITH plan AS (
  EXPLAIN (format table) SELECT * FROM bar
)
INSERT INTO plan_audit
SELECT * FROM plan
 WHERE actual_total_time > 12 * interval '100 ms';

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support