Re: Much Ado About COUNT(*)

Manfred Koizar <mkoi-pg@aon.at>

From: Manfred Koizar <mkoi-pg@aon.at>
To: "Jonah H. Harris" <jharris@tvi.edu>
Cc: Mark Kirkwood <markir@coretech.co.nz>, "Jim C. Nasby" <decibel@decibel.org>, Ron Mayer <rm_pg@cheapcomplexdevices.com>, Bruce Momjian <pgman@candle.pha.pa.us>, pgsql-hackers@postgresql.org
Date: 2005-01-25T07:33:57Z
Lists: pgsql-hackers
On Mon, 24 Jan 2005 08:28:09 -0700, "Jonah H. Harris" <jharris@tvi.edu>
wrote:
>            UPDATE pg_user_table_counts
>                SET rowcount = rowcount + 1
>                WHERE schemaname = this_schemaname
>                    AND tablename = TG_RELNAME;

This might work for small single user applications.  You'll have to keep
an eye on dead tuples in pg_user_table_counts though.

But as soon as there are several concurrent transactions doing both
INSERTs and DELETEs, your solution will in the best case serialise
access to test_tbl or it will break down because of deadlocks.

Servus
 Manfred