Re: getting count for a specific querry

Поиск
Список
Период
Сортировка
От Ragnar Hafstað
Тема Re: getting count for a specific querry
Дата
Msg-id 1112977546.7447.39.camel@localhost.localdomain
обсуждение исходный текст
Ответ на getting count for a specific querry  ("Joel Fradkin" <jfradkin@wazagua.com>)
Ответы Re: getting count for a specific querry  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
On Fri, 2005-04-08 at 09:29 -0400, Joel Fradkin wrote:

> Our app currently pulls a bunch of data to several query pages.
> 
> My idea is to use the limit and offset to return just the first 50
> records, if they hit next I can set the offset.
> 
> My understanding was this gets slower as you move further into the
> data, but we have several options to modify the search, and I do not
> believe our clients will page very far intro a dataset.

you might reduce the performance loss if your dataset is ordered by
a UNIQUE index.

select * from mytable where somecondition                      ORDER by uniquecol limit 50;

and next:

select * from mytable where somecondition AND uniquecol>?                      ORDER by uniquecol limit 50 OFFSET 50;

where the ? is placeholder for last value returned by last query.

if your unique index is a multi-column one, the method is slightly
more complicated, but the same idea.

gnari





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

Предыдущее
От: Ragnar Hafstað
Дата:
Сообщение: Re: getting count for a specific querry
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: getting count for a specific querry