From: | Markus Schaber <schabios(at)logi-track(dot)com> |
---|---|
To: | "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> |
Cc: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Correction of best way to fetch next/prev record based on index |
Date: | 2004-07-27 14:21:17 |
Message-ID: | 20040727162117.6de666b6@kingfisher.intern.logi-track.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
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(at)logi-track(dot)com | www.logi-track.com
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2004-07-27 14:21:32 | Re: best way to fetch next/prev record based on index |
Previous Message | Christopher Kings-Lynne | 2004-07-27 14:19:49 | Re: Automagic tuning |