Re: WIP: log query in auto-explain

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: WIP: log query in auto-explain
Date: 2009-11-22 19:57:16
Message-ID: 4B09979C.1010505@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


I put the attached together a while ago and neglected to send it.
Basically it includes the text of the query being explained in the
explain output.

I think it's more important to include the query text when using
auto_explain than in other explain uses, which is why I did it this way.
But I could be persuaded that we should always include it.

Thoughts? Comments?

cheers

andrew

Attachment Content-Type Size
auto-explain-query.patch text/x-patch 4.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: log query in auto-explain
Date: 2009-11-22 20:48:08
Message-ID: 13756.1258922888@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> I put the attached together a while ago and neglected to send it.
> Basically it includes the text of the query being explained in the
> explain output.

I'm pretty certain this will dump core in some contexts --- you should
not assume that sourceText is always available.

Should we be worried about security implications of displaying the query
text?

> I think it's more important to include the query text when using
> auto_explain than in other explain uses, which is why I did it this way.
> But I could be persuaded that we should always include it.

I think this is just useless noise in every other case.

regards, tom lane


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: WIP: log query in auto-explain
Date: 2009-11-22 23:05:28
Message-ID: 4B09C3B8.5050801@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> I put the attached together a while ago and neglected to send it.
>> Basically it includes the text of the query being explained in the
>> explain output.
>>
>
> I'm pretty certain this will dump core in some contexts --- you should
> not assume that sourceText is always available.
>

Ok, I guess I can insert a check that the sourceText is not null. I
wonder what we are supposed to take an explanation to mean if we can't
say what it is we're explaining.

> Should we be worried about security implications of displaying the query
> text?
>
>

If it is dangerous then surely so is the explanation.

cheers

andrew


From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: log query in auto-explain
Date: 2009-11-24 00:29:25
Message-ID: 20091124092925.B04A.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

> Basically it includes the text of the query being explained in the
> explain output.

I expected the query text is printed in "STATEMENT" section.
Do you mean the query should be merged into "LOG" section?
Are there any situation where "STATEMENT" section does not work?

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: log query in auto-explain
Date: 2009-11-24 03:06:06
Message-ID: 4B0B4D9E.6090202@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Itagaki Takahiro wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
>
>> Basically it includes the text of the query being explained in the
>> explain output.
>>
>
> I expected the query text is printed in "STATEMENT" section.
> Do you mean the query should be merged into "LOG" section?
> Are there any situation where "STATEMENT" section does not work?
>

I mean it should be in the Explain output:

<explain xmlns="http://www.postgresql.org/2009/explain">
<Query-Text>SELECT '' AS zero, BOOLTBL1.*
FROM BOOLTBL1
WHERE booleq(bool 'false', f1);</Query-Text>
<Plan>
<Node-Type>Seq Scan</Node-Type>
<Relation-Name>booltbl1</Relation-Name>
<Alias>booltbl1</Alias>
<Startup-Cost>0.00</Startup-Cost>
<Total-Cost>42.88</Total-Cost>
<Plan-Rows>877</Plan-Rows>
<Plan-Width>1</Plan-Width>
<Filter>booleq(false, f1)</Filter>
</Plan>
</explain>

This is especially important for structured output like XML and/or JSON.
A number of users (including me) badly want to be able to extract the
explain output from the log files with the query text included.

cheers

andrew

>


From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: log query in auto-explain
Date: 2009-11-24 03:13:26
Message-ID: 20091124121326.B069.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

> I mean it should be in the Explain output:
> <explain xmlns="http://www.postgresql.org/2009/explain">
> <Query-Text>SELECT '' AS zero, BOOLTBL1.*
> A number of users (including me) badly want to be able to extract the
> explain output from the log files with the query text included.

I see it's useful for non-text output format.
+1 for the extension.

Also please include the documentation fix because it contains
a sample output using STATEMENT section.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center