X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id DA9D99DCB62 for ; Mon, 27 Feb 2006 10:31:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34241-05 for ; Mon, 27 Feb 2006 10:31:55 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) by postgresql.org (Postfix) with ESMTP id 6BD469DCB4C for ; Mon, 27 Feb 2006 10:31:49 -0400 (AST) Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) by mx2.surnet.cl with ESMTP; 27 Feb 2006 11:52:45 -0300 X-IronPort-AV: i="3.99,385,1131332400"; d="scan'208"; a="31826432:sNHT22548868" Received: from alvh.no-ip.org (201.220.123.141) by cluster.surnet.cl (7.0.043) (authenticated as alvherre@surnet.cl) id 43A978FD00866C1C; Mon, 27 Feb 2006 11:31:53 -0300 Received: by alvh.no-ip.org (Postfix, from userid 1000) id 34262C3A397; Mon, 27 Feb 2006 11:31:53 -0300 (CLST) Date: Mon, 27 Feb 2006 11:31:53 -0300 From: Alvaro Herrera To: Csaba Nagy Cc: postgres performance list Subject: Re: neverending vacuum Message-ID: <20060227143153.GC5755@surnet.cl> Mail-Followup-To: Csaba Nagy , postgres performance list References: <1141047092.6846.256.camel@coppola.muc.ecircle.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1141047092.6846.256.camel@coppola.muc.ecircle.de> User-Agent: Mutt/1.5.11+cvs20060126 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.731 required=5 tests=[AWL=-0.188, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] X-Spam-Score: 1.731 X-Spam-Level: * X-Archive-Number: 200602/416 X-Sequence-Number: 17402 Csaba Nagy wrote: > I have a quite big table (about 200 million records, and ~2-3 million > updates/~1 million inserts/few thousand deletes per day). I started a > vacuum on it on friday evening, and it still runs now (monday > afternoon). I used "vacuum verbose", and the output looks like: > > [vacuums list all the indexes noting how many tuples it cleaned, then > "restarts" and lists all the indexes again, then again ... ad nauseam] What happens is this: the vacuum commands scans the heap and notes which tuples need to be removed. It needs to remember them in memory, but memory is limited; it uses the maintenance_work_mem GUC setting to figure out how much to use. Within this memory it needs to store the TIDs (absolute location) of tuples that need to be deleted. When the memory is filled, it stops scanning the heap and scans the first index, looking for pointers to any of the tuples that were deleted in the heap. Eventually it finds them all and goes to the next index: scan, delete pointers. Next index. And so on, until all the indexes are done. At this point, the first pass is done. Vacuum must then continue scanning the heap for the next set of TIDs, until it finds enough to fill maintenance_work_mem. Scan the indexes to clean them. Start again. And again. So one very effective way of speeding this process up is giving the vacuum process lots of memory, because it will have to do fewer passes at each index. How much do you have? -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support