pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Brown <kevin@sysexperts.com>
To: 'pgsql-hackers@postgresql.org' <pgsql-hackers@postgresql.org>
Subject: Re: [PERFORM] not using index for select min(...)
Date: Sat, 1 Feb 2003 08:43:37 -0800
Message-ID: <20030201164336.GP12957@filer> (raw)
In-Reply-To: <4278.1044074132@sss.pgh.pa.us>
References: <FE045D4D9F7AED4CBFF1B3B813C8533701023616@mail.sandvine.com>
	<200301311531.12605.josh@agliodbs.com>
	<20030201040954.GK15936@perrin.int.nxad.com>
	<4278.1044074132@sss.pgh.pa.us>

Tom Lane wrote:
> Sean Chittenden <sean@chittenden.org> writes:
> > Now, there are some obvious problems:
> 
> You missed the real reason why this will never happen: it completely
> kills any prospect of concurrent updates.  If transaction A has issued
> an update on some row, and gone and modified the relevant aggregate
> cache entries, what happens when transaction B wants to update another
> row?  It has to wait for A to commit or not, so it knows whether to
> believe A's changes to the aggregate cache entries.
> 
> For some aggregates you could imagine an 'undo' operator to allow
> A's updates to be retroactively removed even after B has applied its
> changes.  But that doesn't work very well in general.  And in any case,
> you'd have to provide serialization interlocks on physical access to
> each of the aggregate cache entries.  That bottleneck applied to every
> update would be likely to negate any possible benefit from using the
> cached values.

Hmm...any chance, then, of giving aggregate functions a means of
asking which table(s) and column(s) the original query referred to so
that it could do proper optimization on its own?  For instance, for a
"SELECT min(x) FROM mytable" query, the min() function would be told
upon asking that it's operating on column x of mytable, whereas it
would be told "undefined" for the column if the query were "SELECT
min(x+y) FROM mytable".  In the former case, it would be able to do a
"SELECT x FROM mytable ORDER BY x LIMIT 1" on its own, whereas in the
latter it would have no choice but to fetch the data to do its
calculation via the normal means.

But that may be more trouble than it's worth, if aggregate functions
aren't responsible for retrieving the values they're supposed to base
their computations on, or if it's not possible to get the system to
refrain from prefetching data for the aggregate function until the
function asks for it.

-- 
Kevin Brown					      kevin@sysexperts.com



view thread (12+ messages)  latest in thread

Message-ID: <20030201164336.GP12957@filer>
Permalink:  ../20030201164336.GP12957@filer/
Also on:    postgresql.org/message-id/20030201164336.GP12957@filer

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: kevin@sysexperts.com, pgsql-hackers@postgresql.org
  Subject: Re: [PERFORM] not using index for select min(...)
  In-Reply-To: <20030201164336.GP12957@filer>
  References: <FE045D4D9F7AED4CBFF1B3B813C8533701023616@mail.sandvine.com> <200301311531.12605.josh@agliodbs.com> <20030201040954.GK15936@perrin.int.nxad.com> <4278.1044074132@sss.pgh.pa.us> <20030201164336.GP12957@filer>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox