Re: Yet Another COUNT(*)...WHERE...question

Поиск
Список
Период
Сортировка
От Rainer Bauer
Тема Re: Yet Another COUNT(*)...WHERE...question
Дата
Msg-id 7cq8c3dar3u22at8i7siiqfigsm45dr52c@4ax.com
обсуждение исходный текст
Ответ на Re: Yet Another COUNT(*)...WHERE...question  (Gregory Stark <stark@enterprisedb.com>)
Список pgsql-general
Martijn van Oosterhout wrote:

>On Thu, Aug 16, 2007 at 01:09:32PM +0200, Rainer Bauer wrote:
>> Anyway, what Phoenix is trying to say is that 2 queries are required: One to
>> get the total count and one to get the tuples for the current page. I reckon
>> it would help, if the query returning the result set could also report the
>> total no. of tuples found. Somthing like
>> SELECT COUNT(*), *  FROM <table> WHERE <cond> OFFSET <o> LIMIT <l>
>
>Well, thee is another possibility, use cursors:
>
>DECLARE CURSOR ... AS <query>;
>FETCH 30  -- or however many to want now
>MOVE TO END  -- or whatever the command is, this gives you the number of rows
>
>Hope this helps,

Thanks! I will give this a try.

Rainer

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

Предыдущее
От: Rainer Bauer
Дата:
Сообщение: Re: Yet Another COUNT(*)...WHERE...question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: how to get id of currently executed query?