Correction of best way to fetch next/prev record based on index

Поиск
Список
Период
Сортировка
От Markus Schaber
Тема Correction of best way to fetch next/prev record based on index
Дата
Msg-id 20040727162117.6de666b6@kingfisher.intern.logi-track.com
обсуждение исходный текст
Ответ на Re: best way to fetch next/prev record based on index  (Markus Schaber <schabios@logi-track.com>)
Список 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@logi-track.com | www.logi-track.com

В списке pgsql-performance по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: best way to fetch next/prev record based on index
Следующее
От: andrew@pillette.com
Дата:
Сообщение: Re: best way to fetch next/prev record based on index