Re: Count for pagination

Поиск
Список
Период
Сортировка
От Michael C Rosenstein
Тема Re: Count for pagination
Дата
Msg-id 4DA2F361.7040900@mdibl.org
обсуждение исходный текст
Ответ на Count for pagination  (Jason Long <jason@octgsoftware.com>)
Список pgsql-general
> Any suggestions on how to get the count of all records that could be
> returned

We use a window function to get the total # of records within each of
our paginated queries:

SELECT
   ...
   ,COUNT(*) OVER() fullRowCount
FROM ...
WHERE ...
ORDER BY ...
LIMIT ... OFFSET ...;


While there is a cost to using the window  function, it's faster (for
us) than two separate queries, and, more importantly, it's flexible
enough to work in the 100s of different query contexts we have.

/mcr

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Global Variables in plpgsql
Следующее
От: Dmitriy Igrishin
Дата:
Сообщение: Re: Global Variables in plpgsql