Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 78410632878 for ; Fri, 13 Feb 2009 18:34:58 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 34334-05 for ; Fri, 13 Feb 2009 18:34:54 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from easy2.in-chemnitz.de (easy2.in-chemnitz.de [88.198.17.232]) by mail.postgresql.org (Postfix) with ESMTP id A895C63262E for ; Fri, 13 Feb 2009 18:34:54 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by easy2.in-chemnitz.de (Postfix) with ESMTP id 633E5470015 for ; Fri, 13 Feb 2009 23:34:53 +0100 (CET) Received: from easy2.in-chemnitz.de ([127.0.0.1]) by localhost (easy.in-chemnitz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j2Lm5+-VgzFM for ; Fri, 13 Feb 2009 23:34:53 +0100 (CET) Received: by easy2.in-chemnitz.de (Postfix, from userid 1013) id 52746470006; Fri, 13 Feb 2009 23:34:53 +0100 (CET) Date: Fri, 13 Feb 2009 23:34:53 +0100 From: Tino Schwarze To: pgsql-admin@postgresql.org Subject: Re: Vacuum wait time problem Message-ID: <20090213223453.GH12562@easy2.in-chemnitz.de> References: <4995ABC0.4090401@musicreports.com> <4995EC90.5020200@musicreports.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200902/93 X-Sequence-Number: 31314 On Fri, Feb 13, 2009 at 03:13:28PM -0700, Scott Marlowe wrote: [...] > Yeah, that's pretty bad. ~2 Million live rows and ~18 Million dead > ones is a pretty badly bloated table. > > Vacuum full is one way to reclaim that lost space. You can also dump > and restore that one table, inside a drop / create restraints in a > transaction during maintenance if you can. A Vacuum full is quite > intrusive, so avoid it during normal working hours. Dumping and > reloading the whole db may be faster than either a vacuum full or a > cluster. A common trick is to do something like: > > begin; > select * into ordermydata from bigbloatedtable order by some_field; > delete * from bigbloatedtable; > insert into bigbloatedtable select * from ordermydata; > commit; > > This will both put your table in some order which might help, and > remove the bloat. Really? Wouldn't that add even more bloat? How does that work? (I'd expect a drop table/create table instead of the delete...) Note: I suppose that you know a lot more about PG than I do, so I'm just curious. Thanks, Tino. -- "What we nourish flourishes." - "Was wir nähren erblüht." www.lichtkreis-chemnitz.de www.craniosacralzentrum.de