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 19FB4D7F97 for ; Fri, 25 Nov 2005 15:40:10 -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 76037-02 for ; Fri, 25 Nov 2005 19:40:09 +0000 (GMT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.202]) by svr1.postgresql.org (Postfix) with ESMTP id 63AB5D6FE3 for ; Fri, 25 Nov 2005 15:40:05 -0400 (AST) Received: by xproxy.gmail.com with SMTP id s19so1565452wxc for ; Fri, 25 Nov 2005 11:40:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SWqUATreWpkUqOlNonwH4bX2BtsD7rmaX6V6RW7YnYPAz3ST5YMsfFcIFRSitdJ4j71XGdpWojiku4gYk3PT8DxsYkr8O6jSQu4xyc0VXZmgomcGRGIO+FnJ11CEWLr1AfXi2yruFXKOcK66f+PadaW821tbE8Rlaa/4UpNSCjI= Received: by 10.65.206.3 with SMTP id i3mr8690384qbq; Fri, 25 Nov 2005 11:40:06 -0800 (PST) Received: by 10.65.180.14 with HTTP; Fri, 25 Nov 2005 11:40:06 -0800 (PST) Message-ID: Date: Fri, 25 Nov 2005 14:40:06 -0500 From: Jaime Casanova To: Rodrigo Madera Subject: Re: Newbie question: ultra fast count(*) Cc: pgsql-performance@postgresql.org In-Reply-To: <3cf983d0511251136j1afa0ec4i9a3987d250befe47@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <3cf983d0511251136j1afa0ec4i9a3987d250befe47@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.364 required=5 tests=[AWL=0.364] X-Spam-Score: 0.364 X-Spam-Level: X-Archive-Number: 200511/514 X-Sequence-Number: 15771 On 11/25/05, Rodrigo Madera wrote: > I have been reading all this technical talk about costs and such that > I don't (_yet_) understand. > > Now I'm scared... what's the fastest way to do an equivalent of > count(*) on a table to know how many items it has? > > Thanks, > Rodrigo > you really *need* this? you can do SELECT reltuples FROM pg_class WHERE relname =3D 'your_table_name'; but this will give you an estimate... if you want real values you can make a TRIGGER that maintain a counter in another table -- regards, Jaime Casanova (DBA: DataBase Aniquilator ;)