Re: Hardware/OS recommendations for large databases ( - Mailing list pgsql-performance

From Greg Stark
Subject Re: Hardware/OS recommendations for large databases (
Date
Msg-id 87d5kqkpd2.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Hardware/OS recommendations for large databases (  (Mark Kirkwood <markir@paradise.net.nz>)
Responses Re: Hardware/OS recommendations for large databases (
List pgsql-performance
Mark Kirkwood <markir@paradise.net.nz> writes:

> Yeah - it's pretty clear that the count aggregate is fairly expensive wrt cpu -
> However, I am not sure if all agg nodes suffer this way (guess we could try a
> trivial aggregate that does nothing for all tuples bar the last and just
> reports the final value it sees).

As you mention count(*) and count(1) are the same thing.

Last I heard the reason count(*) was so expensive was because its state
variable was a bigint. That means it doesn't fit in a Datum and has to be
alloced and stored as a pointer. And because of the Aggregate API that means
it has to be allocated and freed for every tuple processed.

There was some talk of having a special case API for count(*) and maybe
sum(...) to avoid having to do this.

There was also some talk of making Datum 8 bytes wide on platforms where that
was natural (I guess AMD64, Sparc64, Alpha, Itanic).

Afaik none of these items have happened but I don't know for sure.

--
greg

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: xlog flush request error
Next
From: Tom Lane
Date:
Subject: Re: Hardware/OS recommendations for large databases (