Re: Paged Query - Mailing list pgsql-performance

From Craig Ringer
Subject Re: Paged Query
Date
Msg-id 4FFB6E45.50708@ringerc.id.au
Whole thread Raw
In response to Re: Paged Query  (Misa Simic <misa.simic@gmail.com>)
Responses Re: Paged Query
List pgsql-performance
On 07/10/2012 06:24 AM, Misa Simic wrote:
> Hi Andrew,
>
> Sure... We are sending data in Json to clients
>
> {
> total:6784,
> data:[50 rows for desired page]
> }
>
> SELECT count(*) FROM table - without where, without joins used to have
> bad performance... However, in real scenario we have never had the case
> without joins and where... Join columns are always indexed, and we
> always try to put indexes on columns what will mostly be used in where
> in usual queries...

When/if you do need a count of a single table without any filters, a
common trick is to use table statistics to return an approximation. If
your autovaccum is running regularly it's usually a very good
approximation, too.

Sounds like this hack may become unnecessary in 9.2 though.

--
Craig Ringer

pgsql-performance by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Paged Query
Next
From: Jeff Janes
Date:
Subject: Re: Paged Query