Re: count(*) using index scan in "query often, update rarely" environment

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Cestmir Hybl" <cestmirl(at)freeside(dot)sk>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: count(*) using index scan in "query often, update rarely" environment
Date: 2005-10-07 13:42:32
Message-ID: 3254.1128692552@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Cestmir Hybl" <cestmirl(at)freeside(dot)sk> writes:
> Isn't it possible (and reasonable) for these environments to keep track =
> of whether there is a transaction in progress with update to given table =
> and if not, use an index scan (count(*) where) or cached value =
> (count(*)) to perform this kind of query?

Please read the archives before bringing up such well-discussed issues.

There's a workable-looking design in the archives (pghackers probably)
for maintaining overall table counts in a separate table, with each
transaction adding one row of "delta" information just before it
commits. I haven't seen anything else that looks remotely attractive.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2005-10-07 13:50:30 Re: count(*) using index scan in "query often, update rarely" environment
Previous Message Lane Van Ingen 2005-10-07 13:37:44 Re: Need Some Suggestions