From: Craig Ringer <ringerc@ringerc.id.au>
To: Misa Simic <misa.simic@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Paged Query
Date: Tue, 10 Jul 2012 07:50:29 +0800
Message-ID: <4FFB6E45.50708@ringerc.id.au> (raw)
In-Reply-To: <-6943177787207849568@unknownmsgid>
References: <-6943177787207849568@unknownmsgid>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: ringerc@ringerc.id.au, misa.simic@gmail.com, andrew@dunslane.net
Subject: Re: Paged Query
In-Reply-To: <4FFB6E45.50708@ringerc.id.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox