Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 607D864FD32 for ; Tue, 28 Oct 2008 14:04:11 -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 21190-02 for ; Tue, 28 Oct 2008 14:04:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail137076.authsmtp.co.uk (outmail137076.authsmtp.co.uk [62.13.137.76]) by postgresql.org (Postfix) with ESMTP id 12D2464FCFD for ; Tue, 28 Oct 2008 14:04:07 -0300 (ADT) Received: from mail-c189.authsmtp.com (mail-c189.authsmtp.com [62.13.128.71]) by punt4.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m9SH3KG0045266; Tue, 28 Oct 2008 17:03:20 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 m9SH3Hr1061417; Tue, 28 Oct 2008 17:03:18 GMT Subject: Re: Visibility map, partial vacuums From: Simon Riggs To: Heikki Linnakangas Cc: PostgreSQL-development In-Reply-To: <4905AE17.7090305@enterprisedb.com> References: <4905AE17.7090305@enterprisedb.com> Content-Type: text/plain Date: Tue, 28 Oct 2008 17:03:15 +0000 Message-Id: <1225213395.3971.217.camel@ebony.2ndQuadrant> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Server-Quench: 52886e91-a512-11dd-bc7a-001f29070be2 X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadBtFag1bYlpF HGQLW1xEUVp7WWB/ aQofZQBDYEtPQQxj TklLQE1QEQdtHhxP Wxd9KhoKNQRGfn90 ZEEsX3dYVQp/d051 RBtdFHBXYGZidWEe BBRFJVBTIR5Kfh4T aFl/U3NfNGdJBC9q VzwTFhsSEA9kHWxr QxoMJ1MWQFoaVjs1 X1RKBTw1AUwMQ20t Jhc7N1sHdDg2 X-Authentic-SMTP: 61633235383639.kestrel.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/1424 X-Sequence-Number: 126441 On Mon, 2008-10-27 at 14:03 +0200, Heikki Linnakangas wrote: > Lazy VACUUM only needs to visit pages that are '0' in the visibility > map. This allows partial vacuums, where we only need to scan those parts > of the table that need vacuuming, plus all indexes. Just realised that this means we still have to visit each block of a btree index with a cleanup lock. That means the earlier idea of saying I don't need a cleanup lock if the page is not in memory makes a lot more sense with a partial vacuum. 1. Scan all blocks in memory for the index (and so, don't do this unless the index is larger than a certain % of shared buffers), 2. Start reading in new blocks until you've removed the correct number of tuples 3. Work through the rest of the blocks checking that they are either in shared buffers and we can get a cleanup lock, or they aren't in shared buffers and so nobody has them pinned. If you step (2) intelligently with regard to index correlation you might not need to do much I/O at all, if any. (1) has a good hit ratio because mostly only active tables will be vacuumed so are fairly likely to be in memory. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support