X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D973BDBD00 for ; Thu, 24 Nov 2005 18:08:01 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06557-10 for ; Thu, 24 Nov 2005 22:08:03 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [203.96.152.180]) by svr1.postgresql.org (Postfix) with ESMTP id 1DC67DBCCA for ; Thu, 24 Nov 2005 18:07:59 -0400 (AST) Received: from smtp-1.paradise.net.nz (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IQH00L32C5AXK@linda-1.paradise.net.nz> for pgsql-performance@postgresql.org; Fri, 25 Nov 2005 11:08:00 +1300 (NZDT) Received: from [192.168.1.11] (218-101-28-43.dsl.clear.net.nz [218.101.28.43]) by smtp-1.paradise.net.nz (Postfix) with ESMTP id 56F1EEF76AF; Fri, 25 Nov 2005 11:07:52 +1300 (NZDT) Date: Fri, 25 Nov 2005 11:07:50 +1300 From: Mark Kirkwood Subject: Re: Hardware/OS recommendations for large databases ( In-reply-to: <14286.1132849528@sss.pgh.pa.us> To: Tom Lane Cc: Greg Stark , Luke Lonergan , stange@rentec.com, Dave Cramer , Joshua Marsh , pgsql-performance@postgresql.org Message-id: <438639B6.5090902@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) References: <438583C8.4050809@paradise.net.nz> <87d5kqkpd2.fsf@stark.xeocode.com> <14286.1132849528@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.176 required=5 tests=[AWL=0.176] X-Spam-Score: 0.176 X-Spam-Level: X-Archive-Number: 200511/504 X-Sequence-Number: 15761 Tom Lane wrote: > Greg Stark 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. Cheers Mark