Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id DABF264FD2A for ; Tue, 28 Oct 2008 08:05:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09419-08 for ; Tue, 28 Oct 2008 08:05:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail128144.authsmtp.com (outmail128144.authsmtp.com [62.13.128.144]) by postgresql.org (Postfix) with ESMTP id 05C6A64FC56 for ; Tue, 28 Oct 2008 08:05:37 -0300 (ADT) Received: from mail-c193.authsmtp.com (mail-c193.authsmtp.com [62.13.128.118]) by punt10.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m9SB53ef036702; Tue, 28 Oct 2008 11:05:03 GMT Received: from [192.168.0.3] (85-211-99-122.dyn.gotadsl.co.uk [85.211.99.122]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m9SB51Fr053743; Tue, 28 Oct 2008 11:05:02 GMT Subject: Re: VACUUMs and WAL From: Simon Riggs To: Gregory Stark Cc: pgsql-hackers In-Reply-To: <87bpx5c7dk.fsf@oxford.xeocode.com> References: <1225183785.3971.114.camel@ebony.2ndQuadrant> <87bpx5c7dk.fsf@oxford.xeocode.com> Content-Type: text/plain Date: Tue, 28 Oct 2008 11:04:51 +0000 Message-Id: <1225191891.3971.137.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 45395bde-a4e0-11dd-8a51-002264978518 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFag1bYlpF HGQLW1xEUVx7WWZ/ awkfZQBDYEtPQQxj TklLQE1QEQdtHhxP Wxd9IBxzAUdGfX13 YUUsX3dTWwp+cEV0 RxwAQHBXYTJgdWEe BBRFf1JRcR5Kfh1H bFR2U3sIYG1JBC9q VzEaFA0MGC4XISJZ Cj4kCTpF X-Authentic-SMTP: 61633235383639.pelican.dmpriest.net.uk:1378/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! 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: 200810/1383 X-Sequence-Number: 126400 On Tue, 2008-10-28 at 10:59 +0000, Gregory Stark wrote: > Simon Riggs writes: > > > I don't see a reason why we would issue 2 WAL records per block for a > > VACUUM, nor why we would prune and remove in two steps, dirtying the > > block each time. Seems like we could write approximately half the amount > > of data that we do. > > > > Surely we can come up with a better plan than that one? > > This sounds like the same issue Pavan identified and proposed solving by > rotating the three passes so that we do step 3 at the beginning of the next > vacuum run, so it can be done in the same pass as step 1. > > To do that he proposed we do: > > 1. scan heap doing two things: a) remove any marked tuples if they were marked > by a previous vacuum which committed and b) prune and mark any tuples we > find are deletable for a future vacuum to remove. > > 2. scan indexes and remove the tuples we marked in 1b. It's fairly hard to remove the second heap pass completely. I think what I am suggesting is two heap passes, but writing WAL and dirtying blocks on only one of the passes. The biggest I/O cost comes from the writes, not the reads, ISTM. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support