Re: PostgreSQL Gotchas --- count()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Gregory S(dot) Williamson" <gsw(at)globexplorer(dot)com>, Jeffrey Melloy <jmelloy(at)visualdistortion(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, "Aly S(dot)P Dharshi" <aly(dot)dharshi(at)telus(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL Gotchas --- count()
Date: 2005-10-07 03:15:15
Message-ID: 28622.1128654915@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Gregory S. Williamson wrote:
>> [ re COUNT(*) ]
>> On Informix however it is blindingly fast, and can also be instantly
>> conjured with the dbaccess tool (Info/Table/Status). They might be
>> stashing this count somewhere, but it is not available when the table
>> is locked, as during a load. However they do it, performance does not
>> seem to suffer, and having this rapidly available is certainly nice.
>> Especially when people are used to it.

> Informix locks rows during modification so they don't have the MVCC
> visibility problem we have (some rows are visible to only some
> backends).

More to the point: "performance does not seem to suffer" is an opinion
based on no facts. You have no idea what it's costing Informix to
maintain that count --- ie, how much faster might other things go if
COUNT(*) didn't have to be instant?

We know quite well what it would cost to make this happen in Postgres,
and it's the general judgment that we don't want to pay those costs ---
certainly not to force everyone to pay them.

There's some discussion in the pgsql-hackers archives about possible
add-on mechanisms to maintain COUNT(*) counts on tables for which the
DBA thinks it's justified. It seems clearly doable, but no one's gotten
excited enough to actually do it ... in the end, it seems that everyone
who's looked closely at their application has decided that it wasn't so
important after all.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-10-07 03:25:46 Re: pg_restore --disable-triggers does not stop triggers
Previous Message Tom Lane 2005-10-07 03:00:58 Re: PostgreSQL 8.1 vs. MySQL 5.0?