Re: why does count take so long? - Mailing list pgsql-general

From Tom Lane
Subject Re: why does count take so long?
Date
Msg-id 4889.1063058462@sss.pgh.pa.us
Whole thread Raw
In response to Re: why does count take so long?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: why does count take so long?  (Joseph Shraibman <jks@selectacast.net>)
List pgsql-general
I said:
> Greg Stark <gsstark@mit.edu> writes:
>> Things like count(*) could use int4 until it overflows though.

> I don't see a reasonable way for an aggregate to change state datatype
> on the fly; otherwise this would be a great solution.

On the other hand, the cost is imposed by the generic aggregate
definition that says the aggregate state transition function is an
ordinary function.  This is fine for user-defined aggregates, but there
is no law that says that all the built-in aggregates must use that same
API.  We could probably invent some API that allows COUNT(*) to keep its
running count someplace where it needn't be re-palloc'd on every cycle.
Something to think about for 7.5 (too late for 7.4 I fear).

            regards, tom lane

pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: Can I use PostgreSQL to develop a self-organizing
Next
From: Alvaro Herrera
Date:
Subject: Re: Can I use PostgreSQL to develop a self-organizing