Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 9A3D59FC2D8 for ; Fri, 18 May 2007 10:59:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 55095-08 for ; Fri, 18 May 2007 10:59:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.230]) by postgresql.org (Postfix) with ESMTP id E792D9FC2AA for ; Fri, 18 May 2007 10:59:02 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id s1so1399912nze for ; Fri, 18 May 2007 06:59:01 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YAdpI8vQkaVgenEEgOjrR3WQ1C1VFEmKwqtt4nmqk6N3MGTL/Q83qXWlc6HExhbH0meu0/S13pZymixt/HfKqB6/65lCNwRD7mJu7jwBdTtbfeOIyIBItLhLRno+WQ2bS5hYaHbfMTVoLH7lzqNpf39H545v7uIZAKW0ps8CtEQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OgxlW4dX2hr8E2TqcXvL/59Z/BERIPC38H4r8eA5ghbDNY+jfrLzB/7AMx0OMuJIzktXKuns5Bksd+efPHNp6GXtURKGYVrXWuxcppNmhMmN1SJorFV5b7lcVybXQqJPAKLhXmhgbtSHVNJ4Yd510Ne/jJ2gqPScvCQlSirVueg= Received: by 10.114.120.1 with SMTP id s1mr849956wac.1179496739840; Fri, 18 May 2007 06:58:59 -0700 (PDT) Received: by 10.115.72.5 with HTTP; Fri, 18 May 2007 06:58:59 -0700 (PDT) Message-ID: <48d0cacb0705180658n1ce65297xa9f28d56dd4f8426@mail.gmail.com> Date: Fri, 18 May 2007 10:58:59 -0300 From: "Daniel Cristian Cruz" To: "Jonah H. Harris" Subject: Re: select count(*) from a large table is very slow Cc: "Kenneth Marshall" , "Jessica Richard" , pgsql-admin@postgresql.org In-Reply-To: <36e682920705180630y2c28cdc5m14af94d6d62e1daf@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <133912.35849.qm@web56406.mail.re3.yahoo.com> <20070518131920.GA7069@it.is.rice.edu> <36e682920705180630y2c28cdc5m14af94d6d62e1daf@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/187 X-Sequence-Number: 25507 2007/5/18, Jonah H. Harris : > Yes, a summary table updated by triggers is the only way to have > correct numbers... but you also pay the overhead of maintaining those > numbers on every INSERT/UPDATE statement. If you just need > *reasonable* guesstimates, use reltuples in pg_class after an analyze. Oops... INSERT or DELETE... :) And remember that if using TRUNCATE, it will not run your trigger and you will need to reset the counter manually. Regards... -- Daniel Cristian Cruz