Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks
Дата
Msg-id b42b73150806300924t335c17et25bae6fa9c15c1f6@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
On Mon, Jun 30, 2008 at 8:51 AM, Sam Mason <sam@samason.me.uk> wrote:
>>
>>  select * from foo where (o,pk)>(o,?) order by o limit 10;
>
> Hum, I think I must be missing something.  I'm not sure why you're
> comparing 'o' to itself and you're not putting any ordering constraint
> on the primary key.  I think the query should look closer to:
>
>    SELECT * FROM foo WHERE (o,pk)>($1,$2) ORDER BY o,pk LIMIT 10;
>
> Or am I going mad?

yes, you are correct.  you need to supply at least one value for each
ordered field.  I think this is what the OP was tring to say.

usually it's much simpler than this:
select * from foo where pk > $1 order by pk limit 1;

This will pull up table in pk order which is usually fine.  Any
ordering will do as long as the combination of fields being ordered
are unique.  Adding pk as the second criteria is only needed if you
want to order by a non duplicate field.  If 'o' is a candidate key
this is not required.

btw, the use of OFFSET for this type of problem is actually fairly
terrible...it's almost never a good idea.

merlin

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

Предыдущее
От: "Fco. Mario Barcala" Rodríguez
Дата:
Сообщение: multi-word expression full-text searching
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: multi-word expression full-text searching