pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <markir@paradise.net.nz>
To: Luke Lonergan <llonergan@greenplum.com>
Cc: pgsql-performance@postgresql.org, "eng@intranet.greenplum.com" <eng@intranet.greenplum.com>
Subject: Re: Hardware/OS recommendations for large databases (
Date: Thu, 24 Nov 2005 18:34:03 +1300
Message-ID: <438550CB.5020506@paradise.net.nz> (raw)
In-Reply-To: <BFAA659D.145E5%llonergan@greenplum.com>
References: <BFAA659D.145E5%llonergan@greenplum.com>

Luke Lonergan wrote:
> Mark,
> 
> This is an excellent idea – unfortunately I’m in Maui right now 
> (Mahalo!) and I’m not getting to testing with this.  My first try was 
> with 8.0.3 and it’s an 8.1 function I presume.
> 
> Not to be lazy – but any hint as to how to do the same thing for 8.0?
> 

Yeah, it's 8.1 - I didn't think to check against 8.0. The attached 
variant works with 8.0.4 (textToQualifiedNameList needs 2 args)

cheers

Mark

P.s. Maui eh, sounds real nice.

Attachments:

fastcount-8.0.c (text/plain, 1.0K) download /* * fastcount.c * * Do a count that uses considerably less CPU time than an aggregate. * * (Variant for 8.0.x - textToQualifiedNameList needs 2 args) */ #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); }

view thread (173+ messages)  latest in thread

Message-ID: <438550CB.5020506@paradise.net.nz>
Permalink:  ../438550CB.5020506@paradise.net.nz/
Also on:    postgresql.org/message-id/438550CB.5020506@paradise.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: markir@paradise.net.nz, llonergan@greenplum.com, eng@intranet.greenplum.com
  Subject: Re: Hardware/OS recommendations for large databases (
  In-Reply-To: <438550CB.5020506@paradise.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox