Re: [HACKERS] []performance issues

Andrew Sullivan <andrew@libertyrms.info>

From: Andrew Sullivan <andrew@libertyrms.info>
To: PostgreSQL general list <pgsql-general@postgresql.org>
Date: 2002-08-06T21:45:00Z
Lists: pgsql-hackers, pgsql-general
On Fri, Aug 02, 2002 at 02:08:02PM -0400, Rod Taylor wrote:
> 
> Of course, as suggested this is easily overcome by keeping your own c
> counter.
> 
> begin;
> insert into bigtable values ();
> update into counttable set count=count+1;
> commit;
> 
> Now you get all the fun concurrency issues -- but fetching the
> information will be quick.   What happens more, the counts, or the
> inserts :)

You could get around this with a trigger that just inserts 1 into one
table (call it counter_unposted), and then using an external process
to take those units, add them to the value in counter_posted, and
delete them from counter_unposted.  You'd always be a few minutes
behind, but you'd get a counter that's pretty close without too much
overhead.  Of course, this raises the obvious question: why use
count() at all?

A

-- 
----
Andrew Sullivan                               87 Mowat Avenue 
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M6K 3E3
                                         +1 416 646 3304 x110