Re: how to get the total number of records in report

Поиск
Список
Период
Сортировка
От Greg Spiegelberg
Тема Re: how to get the total number of records in report
Дата
Msg-id AANLkTimkTBF-xBfrxM5wNdxrEkP5wKkZGt2GLAynNC_e@mail.gmail.com
обсуждение исходный текст
Ответ на Re: how to get the total number of records in report  (AI Rumman <rummandba@gmail.com>)
Список pgsql-performance
On Tue, Oct 19, 2010 at 1:18 AM, AI Rumman <rummandba@gmail.com> wrote:
Not actualy. I used pagination with limit clause in details query and I need the total number of records in the detail query.


Can you use a cursor?  Roughly...

BEGIN;
DECLARE x CURSOR FOR SELECT * FROM crm;
MOVE FORWARD ALL IN x;
MOVE BACKWARD ALL IN x;
MOVE FORWARD 100 IN x;
FETCH FORWARD 100 FROM x;
CLOSE x;
COMMIT;

Your  application would need to get the actual text result from the "MOVE FORWARD ALL IN x;" statement to know the total number of records from your SELECT.  After that, do your pagination via the "MOVE FORWARD 100 IN x;" and "FETCH FORWARD 100 FROM x;" statements.

HTH.
Greg

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

Предыдущее
От: Jon Nelson
Дата:
Сообщение: Re: odd postgresql performance (excessive lseek)
Следующее
От: Mladen Gogala
Дата:
Сообщение: Re: HashJoin order, hash the large or small table? Postgres likes to hash the big one, why?