Re: Pagination count strategies

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: Pagination count strategies
Дата
Msg-id 20140403140018.GA58047@crankycanuck.ca
обсуждение исходный текст
Ответ на Pagination count strategies  (Leonardo M. Ramé <l.rame@griensu.com>)
Ответы Re: Pagination count strategies
Список pgsql-general
On Thu, Apr 03, 2014 at 10:34:32AM -0300, Leonardo M. Ramé wrote:
>
> What strategy for showing the total number of records returned do you
> recommend?.

The best answer for this I've ever seen is to limit the number of rows
you're counting (at least at first) to some reasonably small number --
say 5000.  This is usually reasonably fast for a well-indexed query,
and your pagination can say something like "First n of at least 5000
results", unless you have fewer than 5000 results, in which case you
know the number (and the count returned quickly anyway).  As you're
displaying those first 5000 results, you can work in the background
getting a more accurate number.  This is more work for your
application, but it provides a much better user experience (and you
can delay getting the detailed number until the user pages through to
the second page of results, so you don't count everything needlessly
in case the user just uses the first page, which IME happens a lot).
Note that even Google doesn't give you an accurate number -- they just
say "about ten trillion" or whatever.

Hope that's useful,

A

--
Andrew Sullivan
ajs@crankycanuck.ca


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

Предыдущее
От: Leonardo M. Ramé
Дата:
Сообщение: Pagination count strategies
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: Pagination count strategies