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 2D3F2DBCB3 for ; Thu, 24 Nov 2005 12:00:47 -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 58710-03 for ; Thu, 24 Nov 2005 16:00:45 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id 6BCB0DBCC9 for ; Thu, 24 Nov 2005 12:00:44 -0400 (AST) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1EfJWM-000338-00; Thu, 24 Nov 2005 11:00:26 -0500 To: Mark Kirkwood Cc: Luke Lonergan , stange@rentec.com, Greg Stark , Dave Cramer , Joshua Marsh , pgsql-performance@postgresql.org Subject: Re: Hardware/OS recommendations for large databases ( References: <438583C8.4050809@paradise.net.nz> In-Reply-To: <438583C8.4050809@paradise.net.nz> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 24 Nov 2005 11:00:25 -0500 Message-ID: <87d5kqkpd2.fsf@stark.xeocode.com> Lines: 24 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[AWL=0.000] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/498 X-Sequence-Number: 15755 Mark Kirkwood 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