X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9B69311F60B8 for ; Fri, 28 Apr 2006 12:03:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 31143-03 for ; Fri, 28 Apr 2006 12:03:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from skynet.simkin.ca (skynet.simkin.ca [199.175.137.210]) by postgresql.org (Postfix) with ESMTP id CE34711F60A0 for ; Fri, 28 Apr 2006 12:03:16 -0300 (ADT) Received: from charon.medialogik.com (S0106000c6eb33e73.vf.shawcable.net [70.68.174.20]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by skynet.simkin.ca (Postfix) with ESMTP id 13B63FAB9 for ; Fri, 28 Apr 2006 08:03:15 -0700 (PDT) From: Alan Hodgson Organization: Simkin Network Consulting To: pgsql-performance@postgresql.org Subject: Re: Why so slow? Date: Fri, 28 Apr 2006 08:02:59 -0700 User-Agent: KMail/1.8.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604280802.59696@hal.medialogik.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/673 X-Sequence-Number: 18757 On April 28, 2006 04:41 am, "Bealach-na Bo" wrote: > INFO: index "job_log_id_pkey" now contains 10496152 row versions in > 59665 pages See the 10496152 above? That means you have 10496152 rows of data in your table. If those, only 365000 are alive. That means you have basically never vacuumed this table before, correct? Every update or delete creates a new dead row. count(*) scans the whole table, dead rows included. That's why it takes so long, the table acts as though it has 10496152 rows when doing sequential scans. Do a VACCUM FULL on it or CLUSTER it on on a index, both of which will empty out all the free space and make it behave as it should. Note; VACUUM FULL will take quite a while and requires an exclusive lock on the table. CLUSTER also requires an exclusive lock but should be a lot faster for this table. Oh, and get autovacuum setup and working, posthaste. -- No long, complicated contracts. No actuarial tables to pore over. Social Security operates on a very simple principle: the politicians take your money from you and squander it "