Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id A311D2E0059 for ; Wed, 23 Apr 2008 16:50:29 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 72215-06 for ; Wed, 23 Apr 2008 16:50:15 -0300 (ADT) X-Greylist: delayed 00:12:14.791293 by SQLgrey-1.7.5 Received: from smtp2.ca.com (smtp2.ca.com [141.202.248.13]) by developer.postgresql.org (Postfix) with ESMTP id 9304C2E0050 for ; Wed, 23 Apr 2008 16:50:18 -0300 (ADT) Received: from athena.ca.com ([130.200.164.17]) by smtp2.ca.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 23 Apr 2008 15:38:02 -0400 Message-ID: <480F8FFF.8080904@ca.com> Date: Wed, 23 Apr 2008 12:37:35 -0700 From: Brian Cox User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: query performance Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 23 Apr 2008 19:38:02.0323 (UTC) FILETIME=[8B171230:01C8A579] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/1185 X-Sequence-Number: 132154 I have a largish (pg_dump output is 4G) database. The query: select count(*) from some-table was taking 120 secs to report that there were 151,000+ rows. This seemed very slow. This db gets vacuum'd regularly (at least once per day). I also did a manual 'vacuum analyze', but after it completed, the query ran no faster. However, after dumping the database and recreating it from the backup, the same query takes 2 secs. Why the dramatic decrease? Would 'vacuum full' have achieved the same performance improvements? Is there anything else that needs to be done regularly to prevent this performance degradation? postgresql 8.1.3 running on redhat es 4. Thanks, Brian