Skip site navigation (1) Skip section navigation (2)

Re: pgsql: Remove item, not sure what it refers to:

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Bruce Momjian <momjian(at)svr1(dot)postgresql(dot)org>,pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Remove item, not sure what it refers to:
Date: 2005-04-25 13:05:47
Message-ID: 200504251305.j3PD5lm28145@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-committers
Kris Jurka wrote:
> 
> 
> On Sat, 23 Apr 2005, Bruce Momjian wrote:
> 
> > Log Message:
> > -----------
> > Remove item, not sure what it refers to:
> > 
> > < * Allow ORDER BY ... LIMIT 1 to select high/low value without sort or
> > <   index using a sequential scan for highest/lowest values
> > < 
> > <   If only one value is needed, there is no need to sort the entire
> > <   table. Instead a sequential scan could get the matching value.
> > <
> 
> This is actually a suggestion from Oleg here:
> 
> http://archives.postgresql.org/pgsql-general/2002-04/msg00464.php
> 
> double min = DBL_MAX;
> for (i=0; i<N; i++) {
>     if (data[i] < min) {
> 	min = data[i];
>     }
> }

OK, so you are saying that right now if we want ORDER BY ... LIMIT 1,
and there is no index, we sort the result then pick the high value,
rather than just doing a sequential scan and grabbing the high/low
value.  Makes sense now.

Thanks, TODO item readded with a clearer description:
	
	* Allow ORDER BY ... LIMIT 1 to select high/low value without sort or
	  index using a sequential scan for highest/lowest values
	
	  Right now, if no index exists, ORDER BY ... LIMIT 1 requires we sort
	  all values to return the high/low value.  Instead The idea is to do a
	  sequential scan to find the high/low value, thus avoiding the sort.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-committers by date

Next:From: Stephen FrostDate: 2005-04-25 13:52:02
Subject: Re: pgsql: Remove item, not sure what it refers to:
Previous:From: Bruce MomjianDate: 2005-04-25 13:03:37
Subject: pgsql: Re-add item with better description: > * Allow ORDER BY ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group