From: Gavin Sherry <swm@alcove.com.au>
To: Tino Wildenhain <tino@wildenhain.de>
Cc: Mark Cotner <mcotner@yahoo.com>
Cc: Dan Harris <fbsd@drivefaster.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Speedier count(*)
Date: Thu, 11 Aug 2005 20:36:58 +1000 (EST)
Message-ID: <Pine.LNX.4.58.0508112035580.1719@linuxworld.com.au> (raw)
In-Reply-To: <1123745049.27613.1.camel@Andrea.peacock.de>
References: <BF204EF7.D9F6%mcotner@yahoo.com>
<1123745049.27613.1.camel@Andrea.peacock.de>
On Thu, 11 Aug 2005, Tino Wildenhain wrote:
> Am Donnerstag, den 11.08.2005, 00:40 -0400 schrieb Mark Cotner:
> > Here's a trigger I wrote to perform essentially the same purpose. The nice
> > thing about this is it keeps the number up to date for you, but you do incur
> > slight overhead.
> ...
> >
> > CREATE TRIGGER del_rowcount_tr BEFORE DELETE ON test FOR EACH ROW EXECUTE
> > PROCEDURE del_rowcount();
> > CREATE TRIGGER add_rowcount_tr BEFORE INSERT ON test FOR EACH ROW EXECUTE
> > PROCEDURE add_rowcount();
> >
> > INSERT INTO rowcount (tablename) VALUES ('test');
> ...
>
> beware of problems with concurrency and even what happens
> if transactions roll back. Maybe you can "fix" it a bit
> by regulary correcting the count via cronjob or so.
What problems? MVCC takes care of this.
Gavin
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: swm@alcove.com.au, tino@wildenhain.de, mcotner@yahoo.com, fbsd@drivefaster.net
Subject: Re: Speedier count(*)
In-Reply-To: <Pine.LNX.4.58.0508112035580.1719@linuxworld.com.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