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 5E3CCDA994 for ; Tue, 22 Nov 2005 01:10:31 -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 80198-04 for ; Tue, 22 Nov 2005 05:10:29 +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 75114DA987 for ; Tue, 22 Nov 2005 01:10:28 -0400 (AST) Received: from smtp-3.paradise.net.nz (tclsnelbe2-src-nat-1 [203.96.152.177]) by linda-1.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IQC00EW2BPFBP@linda-1.paradise.net.nz> for pgsql-performance@postgresql.org; Tue, 22 Nov 2005 18:10:28 +1300 (NZDT) Received: from [192.168.1.11] (218-101-28-59.dsl.clear.net.nz [218.101.28.59]) by smtp-3.paradise.net.nz (Postfix) with ESMTP id 2E104DB4AD3; Tue, 22 Nov 2005 18:10:27 +1300 (NZDT) Date: Tue, 22 Nov 2005 18:10:24 +1300 From: Mark Kirkwood Subject: Re: Hardware/OS recommendations for large databases ( In-reply-to: To: Luke Lonergan Cc: stange@rentec.com, Greg Stark , Dave Cramer , Joshua Marsh , pgsql-performance@postgresql.org Message-id: <4382A840.3030401@paradise.net.nz> MIME-version: 1.0 Content-type: multipart/mixed; boundary=------------030902030501050304090108 X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.6 (X11/20051106) References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.222 required=5 tests=[AWL=0.222] X-Spam-Score: 0.222 X-Spam-Level: X-Archive-Number: 200511/432 X-Sequence-Number: 15689 This is a multi-part message in MIME format. --------------030902030501050304090108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Luke Lonergan wrote: > So that leaves the question - why not more than 64% of the I/O scan rate? > And why is it a flat 64% as the I/O subsystem increases in speed from > 333-400MB/s? > It might be interesting to see what effect reducing the cpu consumption entailed by the count aggregation has - by (say) writing a little bit of code to heap scan the desired relation (sample attached). Cheers Mark --------------030902030501050304090108 Content-Type: text/plain; name="fastcount.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fastcount.c" /* * fastcount.c * * Do a count that uses considerably less CPU time than an aggregate. */ #include "postgres.h" #include "funcapi.h" #include "access/heapam.h" #include "catalog/namespace.h" #include "utils/builtins.h" extern Datum fastcount(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(fastcount); Datum fastcount(PG_FUNCTION_ARGS) { text *relname = PG_GETARG_TEXT_P(0); RangeVar *relrv; Relation rel; HeapScanDesc scan; HeapTuple tuple; int64 result = 0; /* Use the name to get a suitable range variable and open the relation. */ relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname)); rel = heap_openrv(relrv, AccessShareLock); /* Start a heap scan on the relation. */ scan = heap_beginscan(rel, SnapshotNow, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { result++; } /* End the scan and close up the relation. */ heap_endscan(scan); heap_close(rel, AccessShareLock); PG_RETURN_INT64(result); } --------------030902030501050304090108--