X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6EB80D1B1BD for ; Fri, 4 Jun 2004 11:21:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03528-03 for ; Fri, 4 Jun 2004 14:21:47 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 94D1DD1B188 for ; Fri, 4 Jun 2004 11:21:46 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BWFZi-0006kv-00; Fri, 04 Jun 2004 10:21:38 -0400 To: pgsql-general@postgresql.org Subject: Re: VACUUM Question References: <40345D0D.9060103@meerkatsoft.com> In-Reply-To: <40345D0D.9060103@meerkatsoft.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 04 Jun 2004 10:21:38 -0400 Message-ID: <87smdb1k0d.fsf@stark.xeocode.com> Lines: 33 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200406/176 X-Sequence-Number: 61559 Alex writes: > How reasonable is it to run a Vacuum Analyze before and after the > insert/update of the data. On a busy system you should run vacuum more often than once per day. You should probably run a VACUUM after the update. And running ANALYZE at the same time isn't a bad idea, especially if the update changes the distribution a lot. There won't be anything to VACUUM after the insert, but perhaps you still want to run ANALYZE. Note that a plain ANALYZE uses a statistical sample which is much faster, whereas VACUUM ANALYZE has to look at every record anyways so it's slower but produces more accurate statistics. If you don't have performance problems then using VACUUM ANALYZE isn't a bad idea, but it's probably overkill. > Also, I noticed that i get quite some performance improvement if I run a > count(*) on the two tables before the insert. Any reasons for that? Uh, just preloading the kernel cache with blocks from the table and index? > One more question; on one server the Vacuum Analyze before the insert takes > approx. 2min after that the same command takes 15min. You might try a VACUUM FULL sometime when you can deal with 15min of downtime or so. Actually it would probably be longer. Perhaps the table that's taking 15min has a ton of extra dead tuples left over from the fsm settings being too low and/or vacuum being too infrequent. -- greg