Re: count(*) and bad design was: Experiences with extensibility - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: count(*) and bad design was: Experiences with extensibility
Date
Msg-id 20080109105829.37f2958d@commandprompt.com
Whole thread Raw
In response to Re: count(*) and bad design was: Experiences with extensibility  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
Responses Re: count(*) and bad design was: Experiences with extensibility  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: count(*) and bad design was: Experiences with extensibility  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 9 Jan 2008 20:01:05 +0100
Ivan Sergio Borgonovo <mail@webthatworks.it> wrote:

> On Wed, 9 Jan 2008 10:30:45 -0600
> "Scott Marlowe" <scott.marlowe@gmail.com> wrote:
> 
> > Now, everything's a tradeoff.  If PostgreSQL had visibility
> > information in the indexes, it would have to lock both the table and
> > index for every write, thus slowing down all the other queries that
> > are trying to access the table.  It would be a tradeoff that
> > sacrificed write speed for read speed. In a db that was used mostly
> > for writing, it would likely be a fair trade.  In a db that did a
> > lot of writing, it might slow the whole thing to a crawl.
> 
> OK... we are getting near to the point. I understand the trade-off
> problem in storing into indexes id the row is still there.
> Is there a way to get the count of the rows that *may be* there, 

If you analyze regularly you can use pg_class. It isn't exact but is
usually close enough (especially if you are just using it for something
like pagination).

Joshua D. Drake



- -- 
The PostgreSQL Company: Since 1997, http://www.commandprompt.com/ 
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
SELECT 'Training', 'Consulting' FROM vendor WHERE name = 'CMD'


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHhRlVATb/zqfZUUQRAoQmAJ4nkBHmZEsC8UusCT7+qul1Qa9/0QCeJFru
gnBj3ROCMz+vqbF/1Z78roY=
=iVOP
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Ivan Sergio Borgonovo
Date:
Subject: Re: count(*) and bad design was: Experiences with extensibility
Next
From: mljv@planwerk6.de
Date:
Subject: Prepared Statements