Re: Understanding EXPLAIN ANALYZE output

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Fetter <david(at)fetter(dot)org>, Michael Fuhr <mike(at)fuhr(dot)org>, "Ed L(dot)" <pgsql(at)bluepolka(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Understanding EXPLAIN ANALYZE output
Date: 2005-02-11 11:49:59
Message-ID: 20050211114954.GA7055@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 10, 2005 at 10:30:26PM -0500, Tom Lane wrote:
> Well, the point is that there are potentially three types of statements
> involved:
>
> 1. SELECTs
> 2. Utility statements that can return tuples (EXPLAIN, SHOW, etc)
> 3. Utility statements that can't return tuples (ALTER, etc)

<snip>

> The $64 question is whether anyone *needs* to make these distinctions.
> If we arrange to return SPI_OK_SELECT for category 2, then callers won't
> be able to tell the difference between categories 1 and 2, but on the
> other hand a zero-row result set will still be properly classified as
> a SELECT-like operation. If we leave the API as it stands today then a
> zero-row result set looks like a category 3, which arguably is a worse
> categorization.

It occurs to me that distinguishing between 2 and 3 would be useful,
since knowing if there were zero rows returned or nothing should be
returned is a useful distinction. But in the general case, cases 1 and
2 can be distinguished by examining the sent query.

I guess it turns out that "type-of-statement" and "returns-tuples" are
orthoganal concepts and nobody realised this at the time.

> I'm not sure that any of the statements in question actually can return
> zero-row result sets today, but I think it would be bad to make these
> decisions on the basis of assuming that the case will never arise.

What's the right response to "SHOW nonexistant_variable;" ? Currently
it's an error return, which seems reasonable.

I can imagine that there are situations where it would be useful to be
able to extract the output of VACUUM and ANALYZE as resultsets.
However, there's no way for a client to signal it wants a result set.
And just changing the output stops it being logged.

Not an easy choice.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-02-11 11:59:01 Re: Understanding EXPLAIN ANALYZE output
Previous Message Richard Huxton 2005-02-11 11:46:15 Re: SQL query