pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Schaber <schabios@logi-track.com>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: pgsql-performance@postgresql.org
Subject: Correction of best way to fetch next/prev record based on index
Date: Tue, 27 Jul 2004 16:21:17 +0200
Message-ID: <20040727162117.6de666b6@kingfisher.intern.logi-track.com> (raw)
In-Reply-To: <20040727161325.213b11eb@kingfisher.intern.logi-track.com>
References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local>
	<20040727161325.213b11eb@kingfisher.intern.logi-track.com>

Hi, Merlin,

On Tue, 27 Jul 2004 16:13:25 +0200, I myself wrote:


> You mut not

Should be "must", not "mut" :-)

> > My problem is deceptively simple: how you read the next record from
> > a table based on a given set of values?  In practice, this is
> > difficult to implement.  If anybody can suggest a alternative/better
> > way to this, I'm all ears.
> 
> So you really want something like
> 
> 'SELECT * FROM t WHERE a>=a1 AND b>=b1 AND c>=c1 ORDER BY a,b,c ASC
> LIMIT 1'

Sorry, as you want the _next_, and I assume that a1, b1 and c1 are the
current row's values, you should rather use something like:

'SELECT * FROM t WHERE a>=a1 AND b>=b1 AND c>=c1 ORDER BY a,b,c ASC
LIMIT 1 OFFSET 1'

HTH,
Markus

-- 
markus schaber | dipl. informatiker
logi-track ag | rennweg 14-16 | ch 8001 zürich
phone +41-43-888 62 52 | fax +41-43-888 62 53
mailto:schabios@logi-track.com | www.logi-track.com



Message-ID: <20040727162117.6de666b6@kingfisher.intern.logi-track.com>
Permalink:  ../20040727162117.6de666b6@kingfisher.intern.logi-track.com/
Also on:    postgresql.org/message-id/20040727162117.6de666b6@kingfisher.intern.logi-track.com

 · 

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: schabios@logi-track.com, merlin.moncure@rcsonline.com
  Subject: Re: Correction of best way to fetch next/prev record based on index
  In-Reply-To: <20040727162117.6de666b6@kingfisher.intern.logi-track.com>
  References: <6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local> <20040727161325.213b11eb@kingfisher.intern.logi-track.com> <20040727162117.6de666b6@kingfisher.intern.logi-track.com>

* 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