Parsing output of EXPLAIN command in PostgreSQL

Started by Αναστάσιος Αρβανίτηςabout 14 years ago3 messages

I'm developing an application that requires parsing of
execution plans (those produced as output by issuing an EXPLAIN [query]
command). Are you aware of any Java library that I could use for this
purpose? I found https://github.com/depesz/Pg--Explain but it is built in Perl.

Also another option I am considering is to use EXPLAIN [query] FORMAT XML which is available in PostgreSQL 9.1. However, in that case it
would better to have the XML Schema of the generated plans available.

Is there any other solution I am not aware of?

Thank you

#2Andreas Karlsson
andreas@proxel.se
In reply to: Αναστάσιος Αρβανίτης (#1)
Re: Parsing output of EXPLAIN command in PostgreSQL

On 2011-11-10 17:23, οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ wrote:

Also another option I am considering is to use EXPLAIN [query] FORMAT XML which is available in PostgreSQL 9.1. However, in that case it
would better to have the XML Schema of the generated plans available.

Is there any other solution I am not aware of?

Hi,

I recommend using the XML, JSON or YAML version of the plan, whichever
is easiest in your programming language to parse. I do not think anyone
has written a formal schema yet for the XML but it still should be much
easier to parse than rolling your own parser for the human readable format.

But if you insist on parsing the human readable format, e.g. to support
versions before 9.1, I recommend that you take a look at
http://explain.depesz.com/ which supports parsing text plans in addition
to XML and JSON. The site is open source and written in Perl.

The source code can be found at:

https://github.com/depesz/Pg--Explain

Best regards,
Andreas

--
Andreas Karlsson

#3Andreas Karlsson
andreas@proxel.se
In reply to: Andreas Karlsson (#2)
Re: Parsing output of EXPLAIN command in PostgreSQL

On 2011-11-10 23:42, Andreas Karlsson wrote:

Hi,

I recommend using the XML, JSON or YAML version of the plan, whichever
is easiest in your programming language to parse. I do not think anyone
has written a formal schema yet for the XML but it still should be much
easier to parse than rolling your own parser for the human readable format.

But if you insist on parsing the human readable format, e.g. to support
versions before 9.1, I recommend that you take a look at
http://explain.depesz.com/ which supports parsing text plans in addition
to XML and JSON. The site is open source and written in Perl.

The source code can be found at:

https://github.com/depesz/Pg--Explain

Sorry, I did not see the other thread about the same thing. Let's keep
all discussion there.

--
Andreas Karlsson