Re: why does count take so long?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: why does count take so long?
Date: 2003-09-08 22:01:02
Message-ID: 4889.1063058462@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I said:
> Greg Stark <gsstark(at)mit(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-09-08 22:06:11 Re: ISO 8601 'Time Intervals' of the 'format with time-unit deignators'
Previous Message Peter Eisentraut 2003-09-08 21:58:09 Re: ISO 8601 'Time Intervals' of the 'format with time-unit