Re: Indices for select count(*)?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Indices for select count(*)?
Date: 2005-12-23 17:42:02
Message-ID: 20051223174154.GC27014@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 don't think the planner objection need be taken too
> seriously: we already have a good big wart in there for recognizing
> MIN/MAX indexability, and this sort of transformation would fit pretty
> naturally with what's already done in planagg.c.

AFAICS two big problems with using an index type:

1. The index isn't told when the tuple is deleted.
2. The server expects to be able to lookup an index.

Other than that...

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-12-23 18:38:29 Re: Indices for select count(*)?
Previous Message Mag Gam 2005-12-23 17:31:57 Isolate Logs