Re: explain root element for auto-explain

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: explain root element for auto-explain
Date: 2009-08-18 00:11:46
Message-ID: 4A89F1C2.6000203@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(dot)dunstan(at)pgexperts(dot)com> writes:
>
>> The attached tiny patch sets the <explain> root element for auto-explain
>> XML output, so it looks something like this:
>>
>
> This looks reasonable in itself, but it sort of begs the question on
> two other things:
>
> * what's the xmlns URL really going to be?
>

By convention it refers to a place where you publish the schema for the
document type, but it is in fact completely arbitrary, and can refer to
a non-existant resource - as long as it is unique - it's just a
namespace designator, and from an XML POV has no more semantic
significance that a schema name does in SQL.

> * what's the <Query> element in regular XML output good for? And
> shouldn't we make both explain and auto-explain either have that or not?
>
>

and also, why isn't it present in the JSON output for either? We seem to
have several places when we output an XML tag but not a corresponding
named JSON node. Is that really a good idea?

>> The JSON output looks like this:
>>
>
>
>> [
>> "Plan": {
>> "Node Type": "Result",
>> "Startup Cost": 0.00,
>> "Total Cost": 0.01,
>> "Plan Rows": 1,
>> "Plan Width": 0
>> }
>> ]
>>
>
> <squint> Bearing in mind that I know roughly nothing of JSON ... surely
> the above is syntactically incorrect? A labeled value should be within
> {...} not [...]. I think this is closely related to the point about
> <Query>, ie the same semantic nesting level is missing in both cases.
>

Looks like it. <http://www.jsonlint.com/> is useful for checking such
things.

Of course, the current JSON output from auto-explain (i.e. without the
enclosing [ ] ) is also illegal, unlike the output from "explain (format
json) select 1", which encloses the Plan node in { } inside the [ ],

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2009-08-18 00:20:35 Re: explain root element for auto-explain
Previous Message Tom Lane 2009-08-17 23:01:26 Re: [COMMITTERS] pgsql: Add release notes for 8.5alpha1