Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 7BDAA9FB412 for ; Fri, 18 May 2007 10:30:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 06341-03 for ; Fri, 18 May 2007 10:30:33 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.232]) by postgresql.org (Postfix) with ESMTP id 9C7DB9FB394 for ; Fri, 18 May 2007 10:30:38 -0300 (ADT) Received: by nz-out-0506.google.com with SMTP id s1so1388960nze for ; Fri, 18 May 2007 06:30:37 -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=nsyiuMf/I8pMI94HUm9xSHWaFL/ytrWaQzshX5c/KuhmYzA/x/22GgzhK0n85T7tdtkcSlwAM6JLeifdgbAZdsR3Sjvb8wdbEXwXn7uGSAeU7rDd/Wk0zzj7/SRKi5keBDSOjkgj9gCgBS+nqF/ZKa4BIzJrL7RN25FDhRXYU+A= 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=LtbFmCv51yUQr+p5H6sLXXog3ybnwKc2aqOZCA1e9sxGj8Ip6NEF+R9aihC++Fju7eCtd2wry7TWKeK7tjI5Ie5SbMeYFne8Op/SFI5uixVkaRTfAxwCJA8MiLtnL5u0mEFf8qnyV4Ix8LEZr1Na53yS0gSN8kr0pkDXQy3uLA0= Received: by 10.114.15.1 with SMTP id 1mr873612wao.1179495036588; Fri, 18 May 2007 06:30:36 -0700 (PDT) Received: by 10.114.47.12 with HTTP; Fri, 18 May 2007 06:30:36 -0700 (PDT) Message-ID: <36e682920705180630y2c28cdc5m14af94d6d62e1daf@mail.gmail.com> Date: Fri, 18 May 2007 09:30:36 -0400 From: "Jonah H. Harris" To: "Kenneth Marshall" Subject: Re: select count(*) from a large table is very slow Cc: "Jessica Richard" , pgsql-admin@postgresql.org In-Reply-To: <20070518131920.GA7069@it.is.rice.edu> 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> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/186 X-Sequence-Number: 25506 On 5/18/07, Kenneth Marshall wrote: > Make a summary table and select from there instead. 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. -- Jonah H. Harris, Software Architect | phone: 732.331.1324 EnterpriseDB Corporation | fax: 732.331.1301 33 Wood Ave S, 3rd Floor | jharris@enterprisedb.com Iselin, New Jersey 08830 | http://www.enterprisedb.com/