Re: Much Ado About COUNT(*)

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
Cc: Mark Kirkwood <markir(at)coretech(dot)co(dot)nz>, "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>, Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Much Ado About COUNT(*)
Date: 2005-01-25 07:33:57
Message-ID: 42tbv0t8sp8af4vgh8arudal6fnhfpii83@email.aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-hackers pgsql-patches

On Mon, 24 Jan 2005 08:28:09 -0700, "Jonah H. Harris" <jharris(at)tvi(dot)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

In response to

Responses

Browse pgsql-announce by date

  From Date Subject
Next Message Christopher Browne 2005-01-25 12:03:28 Re: Much Ado About COUNT(*)
Previous Message elein 2005-01-25 01:26:05 PostgreSQL General Bits Issue # 94

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-01-25 07:40:51 Re: bug w/ cursors and savepoints
Previous Message Jim C. Nasby 2005-01-25 05:03:03 Built-in casts for ltree

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2005-01-25 07:38:12 Re: add soundex difference function to
Previous Message Kris Jurka 2005-01-25 07:26:31 Re: add soundex difference function to contrib/fuzzystrmatch