I have been working on a project (for GSOC) to retrieve
planner/optimizer details. As part of the project, I need machine
parsable output. So, I thought I would dust off a patch I found from
last year that Germán Caamaño submitted. I didn't see any further
activity there so I integrated it into 8.4 and added a DTD.
The output below is generated by using the added flag 'XML' to the
EXPLAIN command. The DTD probably wouldn't be needed for every output
instance and may need its own flag.
I am coming up to speed on the planner internals, but it seems like this
first EXPLAIN XML concept may have some use. Are there any strong
opinions about the XML hierarchy? Is it enough to simply wrap the text
output from EXPLAIN with XML tags?
-Tom Raney
QUERY PLAN
-------------------------------------------------------------------<?xml version="1.0"?>
<!DOCTYPE explain[<!ELEMENT explain (plan+) ><!ELEMENT plan (table?, cost, qualifier?) ><!ELEMENT table EMPTY
><!ELEMENTcost EMPTY ><!ELEMENT qualifier EMPTY ><!ATTLIST explain version CDATA #REQUIRED ><!ATTLIST plan name
CDATA #REQUIRED level CDATA #REQUIRED ><!ATTLIST cost startup CDATA #REQUIRED total CDATA #REQUIRED
rowsCDATA #REQUIRED width CDATA #REQUIRED ><!ATTLIST table name CDATA #REQUIRED ><!ATTLIST qualifier
typeCDATA #REQUIRED value CDATA #REQUIRED >]>
<explain version="8.4devel"><plan name="Seq Scan" level="0"> <table name="tenk1"/> <cost startup="0.00"
total="445.00"rows="10000" width="244" /></plan></explain>
(32 rows)
Greg Smith wrote:
> On Thu, 17 Apr 2008, Tom Lane wrote:
>
>> For debugging the planner work I'm about to do, I'm expecting it will be
>> useful to be able to get EXPLAIN to print the targetlist of each plan
>> node, not just the quals (conditions) as it's historically done.
>
> I've heard that some of the academic users of PostgreSQL were hoping
> to add features in this area in order to allow better using planner
> internals for educational purposes. It would be nice if that were
> available for such purposes without having to recompile.
>
> --
> * Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD
>