Re: Indices for select 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: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Indices for select count(*)?
Date: 2005-12-23 22:45:48
Message-ID: 9979.1135377948@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:
>> On Fri, Dec 23, 2005 at 11:04:50AM -0500, Tom Lane wrote:
>>> It's not that easy --- in the MVCC world there simply isn't a unique
>>> count that is the right answer for every observer. But the idea of
>>> packaging a count(*) mechanism as an index type seems like it might be
>>> a good one.

> I think our TODO has a good summary of the issues:

The point here was the idea that we might implement something like the
delta-counts approach, but package it to look like a specialized index
type --- as opposed to making the user create triggers and so on,
which'd surely be a lot more error-prone to set up. Also, if it were
an index type then it would be relatively straighforward to get the
planner to recognize the availability of a substitute way of doing
COUNT(*). We could do all this in other ways but it'd require more
new infrastructure.

The DELETE problem might kill the idea though.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Campbell, Greg 2005-12-24 00:17:13 Re: ODBC connection string, MS Access
Previous Message Bruce Momjian 2005-12-23 22:16:44 Re: Indices for select count(*)?