Re: [SQL] query to do a backward 'skip', possible with (index) optimization ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] query to do a backward 'skip', possible with (index) optimization ?
Дата
Msg-id 3114.947517469@sss.pgh.pa.us
обсуждение исходный текст
Ответ на query to do a backward 'skip', possible with (index) optimization ?  ("Albert Loo" <albertsql@hotmail.com>)
Список pgsql-sql
"Albert Loo" <albertsql@hotmail.com> writes:
> => select * from mytable where id < '12345' order by id desc limit 1;

> - which returned the correct result '12344', but without optimization.

6.5.* doesn't know how to do that using an index (but 7.0 will).  I seem
to recall that someone posted a patch that partially solved the problem
in 6.5.* sources; check the archives if you are in a hurry.

BTW, I think you're probably going at this the wrong way, because it
doesn't extend to the case of fetching the *next* record in a
prespecified query.  You probably want to use DECLARE CURSOR and FETCH.
        regards, tom lane


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

Предыдущее
От: "Albert Loo"
Дата:
Сообщение: query to do a backward 'skip', possible with (index) optimization ?
Следующее
От: Jude Weaver
Дата:
Сообщение: Simmultanous Connections