Re: How to get the total number of rows returned by query

Поиск
Список
Период
Сортировка
От Shridhar Daithankar
Тема Re: How to get the total number of rows returned by query
Дата
Msg-id 3F705FB1.5020804@persistent.co.in
обсуждение исходный текст
Ответ на How to get the total number of rows returned by query when using a cursor?  ("Egor Shipovalov" <pgsql_list@eonline.ru>)
Ответы Re: How to get the total number of rows returned by query  ("Egor Shipovalov" <pgsql_list@eonline.ru>)
Список pgsql-general
Egor Shipovalov wrote:

> I'm implementing paging through search results using cursors. Is there a
> better way to know total number of rows under a cursor than running a
> separate COUNT(*) query? I think PostgreSQL is bound to know this number
> after the first FETCH, isn't it?

Using libpq, yes. You can use PQntuples. See
http://developer.postgresql.org/docs/postgres/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO

Unfortunately this will retrieve the entire resultselt before returning the
control. When libpq will have chuncking of data, this will be much more
flexible, as you are expecting it now, I guess.

  Shridhar



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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: table size
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: PostgreSQL query failed: ERROR: pg_atoi: zero-length