Skip site navigation (1) Skip section navigation (2)

Re: Hardware/OS recommendations for large databases (

From: Mark Kirkwood <markir(at)paradise(dot)net(dot)nz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Luke Lonergan <llonergan(at)greenplum(dot)com>, stange(at)rentec(dot)com, Dave Cramer <pg(at)fastcrypt(dot)com>, Joshua Marsh <icub3d(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Hardware/OS recommendations for large databases (
Date: 2005-11-24 22:07:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Tom Lane wrote:
> Greg Stark <gsstark(at)mit(dot)edu> writes:
>>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's a hack in 8.1 to avoid the palloc overhead (courtesy of Neil
> Conway IIRC).

It certainly makes quite a difference as I measure it:

doing select(1) from a 181000 page table (completely uncached) on my PIII:

8.0 : 32 s
8.1 : 25 s

Note that the 'fastcount()' function takes 21 s in both cases - so all 
the improvement seems to be from the count overhead reduction.



In response to

pgsql-performance by date

Next:From: Pailloncy Jean-GerardDate: 2005-11-24 23:34:16
Subject: Re: 8.1 count(*) distinct: IndexScan/SeqScan
Previous:From: Bealach-na BoDate: 2005-11-24 18:51:42
Subject: Very slow queries - please help

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group