From: Robert Treat <xzilla@users.sourceforge.net>
To: david@shadovitz.com <david@shadovitz.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Cc: 'Richard Huxton' <dev@archonet.com>
Subject: Re: COUNT & Pagination
Date: 12 Jan 2004 16:42:12 -0500
Message-ID: <1073943732.29178.153.camel@camel> (raw)
In-Reply-To: <01C3D8DF.271378C0.david@shadovitz.com>
References: <01C3D8DF.271378C0.david@shadovitz.com>
On Mon, 2004-01-12 at 10:37, David Shadovitz wrote:
> > If you only need the count when you've got the results, most PG client
> > interfaces will tell you how many rows you've got. What language is your app
> > in?
>
> PHP.
> But I have only a subset of the results, retrieved via a query with a "LIMIT
> <m>" clause, so $pg_numrows is m.
> And retrieving all results (i.e. no LIMIT) is at least as expensive as
> COUNT(*).
>
Depending on frequency of updates and need for real time info, you could
cache the count in session as long as the user stays within the given
piece of your app.
Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
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: xzilla@users.sourceforge.net, david@shadovitz.com, dev@archonet.com
Subject: Re: COUNT & Pagination
In-Reply-To: <1073943732.29178.153.camel@camel>
* 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