Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A93189FCB81 for ; Thu, 8 Nov 2007 10:49:53 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 48403-09 for ; Thu, 8 Nov 2007 10:49:33 -0400 (AST) Received: from pat.uio.no (pat.uio.no [129.240.10.15]) by postgresql.org (Postfix) with ESMTP id 6F07C9FCB86 for ; Thu, 8 Nov 2007 10:49:41 -0400 (AST) Received: from mail-mx6.uio.no ([129.240.10.47]) by pat.uio.no with esmtp (Exim 4.67) (envelope-from ) id 1Iq8hP-0002xj-Mn; Thu, 08 Nov 2007 15:49:39 +0100 Received: from smtp.uio.no ([129.240.10.9] helo=mail-mx6.uio.no) by mail-mx6.uio.no with esmtp (Exim 4.67) (envelope-from ) id 1Iq8hN-0006OW-7i; Thu, 08 Nov 2007 15:49:37 +0100 Received: from bbking.uio.no ([129.240.201.179]) by mail-mx6.uio.no with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1Iq8hN-0006OQ-4D; Thu, 08 Nov 2007 15:49:37 +0100 Message-ID: <47332200.9050705@usit.uio.no> Date: Thu, 08 Nov 2007 15:49:36 +0100 From: Rafael Martinez User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Heikki Linnakangas CC: pgsql-performance@postgresql.org Subject: Re: Need to run CLUSTER to keep performance References: <4732E6B4.1030907@usit.uio.no> <4732EF07.3060807@enterprisedb.com> In-Reply-To: <4732EF07.3060807@enterprisedb.com> X-Enigmail-Version: 0.95.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-UiO-Resend: resent X-UiO-ClamAV-Virus: No X-UiO-Spam-info: not spam, SpamAssassin (score=-4.7, required=12.0, autolearn=disabled, AWL=0.332, UIO_MAIL_IS_INTERNAL=-5) X-UiO-Scanned: 73017BEBB9486D3D8FD7219578A82CE202091461 X-UiO-Ratelimit-Test: Ratelimit X-UiO-SPAM-Test: UIO-RATELIMIT remote_host: 129.240.10.9 spam_score: -46 maxlevel 200 minaction 2 bait 0 mail/h: 1613 total 5008788 max/h 8345 blacklist 0 greylist 0 ratelimit 1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/96 X-Sequence-Number: 27511 Heikki Linnakangas wrote: > Rafael Martinez wrote: >> The tables with this 'problem' are not big, so CLUSTER finnish very fast >> and it does not have an impact in the access because of locking. But we >> wonder why this happens. > > 2 seconds for seq scanning 12 MB worth of data sounds like a lot. Have > you increased shared_buffers from the default? Which operating system > are you using? Shared memory access is known to be slower on Windows. > This is a server with 8GB of ram, we are using 25% as shared_buffers. Linux RHELAS4 with a 2.6.9-55.0.9.ELsmp kernel / x86_64. > On a small table like that you could run VACUUM every few minutes > without much impact on performance. That should keep the table size in > check. > Ok, we run VACUUM ANALYZE only one time a day, every night. But we would espect the performance to get ok again after running vacuum, and it doesn't. Only CLUSTER helps. I can not see we need to change the max_fsm_pages parameter and pg_class and analyze give us this information today (not long ago a CLUSTER was executed): ------------------------------------------------------------------------------ scanorama=# VACUUM VERBOSE ANALYZE hosts; INFO: vacuuming "public.hosts" INFO: index "hosts_pkey" now contains 20230 row versions in 117 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: "hosts": found 0 removable, 20230 nonremovable row versions in 651 pages DETAIL: 3790 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 0.00s/0.00u sec elapsed 0.01 sec. INFO: vacuuming "pg_toast.pg_toast_376127" INFO: index "pg_toast_376127_index" now contains 131 row versions in 2 pages DETAIL: 0 index pages have been deleted, 0 are currently reusable. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: "pg_toast_376127": found 0 removable, 131 nonremovable row versions in 33 pages DETAIL: 0 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: analyzing "public.hosts" INFO: "hosts": scanned 651 of 651 pages, containing 16440 live rows and 3790 dead rows; 16440 rows in sample, 16440 estimated total rows VACUUM scanorama=# SELECT relname, relpages, reltuples from pg_class WHERE relname LIKE 'hosts'; relname | relpages | reltuples ---------+----------+----------- hosts | 651 | 20230 ------------------------------------------------------------------------------ Anymore ideas? regards, -- Rafael Martinez, Center for Information Technology Services University of Oslo, Norway PGP Public Key: http://folk.uio.no/rafael/