Received: from gumby.usu.edu (gumby.usu.edu [129.123.1.117]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eAI0C0s76908 for ; Fri, 17 Nov 2000 19:12:01 -0500 (EST) (envelope-from rmello@cc.usu.edu) Received: from cc.usu.edu ("port 4107"@slxwy.dorms.usu.edu [129.123.236.160]) by cc.usu.edu (PMDF V5.2-32 #39375) with ESMTP id <01JWNKFOCC6A90NCT7@cc.usu.edu> for pgsql-sql@postgresql.org; Fri, 17 Nov 2000 17:10:36 MST Date: Fri, 17 Nov 2000 17:11:03 -0700 From: Roberto Mello Subject: Re: how many rows? [was Re: fetching rows]] To: pgsql-sql@postgresql.org Message-id: <3A15C917.E3252F9@cc.usu.edu> MIME-version: 1.0 X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.16 i586) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Accept-Language: en, pt-BR X-Archive-Number: 200011/147 X-Sequence-Number: 178 "Robert B. Easter" wrote: > If someone has done it a better way, I'd like to hear how. However, > sometimes it is possible to cache a count(*) value somewhere in the database > so it doesn't have to be found everytime - it depends on your database and > what the select is if you can store the count in advance somehow. I don't know how it was implemented (source code is available), but the PostgreSQL driver for AOLserver (a kick-butt web server for database-backed websites) has a function that does that. All I do after a SQL statement is: set rowcount [ns_pg ntuples] in my Tcl code and there it is. The driver is available at either http://www.aolserver.com or http://www.openacs.org (the latter has a more elaborate version of the driver). -Roberto -- Computer Science Utah State University Space Dynamics Laboratory Web Developer USU Free Software & GNU/Linux Club http://fslc.usu.edu My home page - http://www.brasileiro.net/roberto