COUNT & Pagination

Поиск
Список
Период
Сортировка
От David Shadovitz
Тема COUNT & Pagination
Дата
Msg-id 01C3D82B.388A7FE0.david@shadovitz.com
обсуждение исходный текст
Ответы Re: COUNT & Pagination  (Jeff Fitzmyers <jeff@cloverpub.com>)
Re: COUNT & Pagination  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Re: COUNT & Pagination  (Richard Huxton <dev@archonet.com>)
Re: COUNT & Pagination  (mallah@trade-india.com)
Re: COUNT & Pagination  (CoL <col@mportal.hu>)
Список pgsql-performance
I understand that COUNT queries are expensive.  So I'm looking for advice on
displaying paginated query results.

I display my query results like this:

  Displaying 1 to 50 of 2905.
  1-50 | 51-100 | 101-150 | etc.

I do this by executing two queries.  One is of the form:

  SELECT <select list> FROM <view/table list> WHERE <filter> LIMIT m OFFSET n

The other is identical except that I replace the select list with COUNT(*).

I'm looking for suggestions to replace that COUNT query.  I cannot use the
method of storing the number of records in a separate table because my queries
(a) involve joins, and (b) have a WHERE clause.

And an unrelated question:
I'm running PG 7.2.2 and want to upgrade to 7.4.1.  I've never upgraded PG
before and I'm nervous.  Can I simply run pg_dumpall, install 7.4.1, and then
feed the dump into psql?  I'm planning to use pg_dumpall rather than pg_dump
because I want to preserve the users I've defined.  My database is the only one
on the system.

Thanks.
-David (who would love to go to Bruce Momjian's boot camp)

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: failures on machines using jfs
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: optimizing Postgres queries