X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9A74356535 for ; Wed, 9 Mar 2005 15:17:03 +0000 (GMT) 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 44352-10 for ; Wed, 9 Mar 2005 15:17:01 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A74435638F for ; Wed, 9 Mar 2005 15:16:58 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j29FGr3v023847; Wed, 9 Mar 2005 10:16:53 -0500 (EST) To: Gaetano Mendola Cc: Richard Huxton , Michael Fuhr , "pgsql-performance@postgresql.org" Subject: Re: vacuum full, why multiple times ? In-reply-to: <422F086F.9080605@bigfoot.com> References: <422E4B15.60806@bigfoot.com> <20050309021533.GB13883@winnie.fuhr.org> <422EDDA2.5000901@bigfoot.com> <422EEC49.7080202@archonet.com> <422F086F.9080605@bigfoot.com> Comments: In-reply-to Gaetano Mendola message dated "Wed, 09 Mar 2005 15:30:07 +0100" Date: Wed, 09 Mar 2005 10:16:52 -0500 Message-ID: <23846.1110381412@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/166 X-Sequence-Number: 10871 Gaetano Mendola writes: > Richard Huxton wrote: >> If page number 8549 was the one being held, I don't think vacuum can >> truncate the file. The empty space can be re-used, but the rows can't be >> moved to a lower page while a transaction is using them. > It's clear now. Not entirely. VACUUM FULL doesn't really worry about whether anyone else "is using" the table --- it knows no one else is, because it holds exclusive lock on the table. However it must preserve dead tuples that would still be visible to any existing transaction, because that other transaction could come along and look at the table after VACUUM finishes and releases the lock. What really drives the process is that VACUUM FULL moves tuples in order to make the file shorter (release empty pages at the end) --- and not for any other reason. So it could stop when there is still plenty of dead space in the table. It stops when the last nonempty page contains a tuple that it can't find room for in any earlier page. What I suppose you saw was that page 8503 contained a tuple so large it wouldn't fit in the free space on any earlier page. By the time of the second vacuum, either this tuple was deleted, or deletion of some other tuples had made a hole big enough for it to fit in. The extent of the truncation in the second vacuum says that you had quite a lot of free space, so it's a bit surprising that there wasn't enough room in any one page for such a tuple to be moved, but that seems to be what happened. regards, tom lane