Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 9F841650174 for ; Wed, 26 Nov 2008 08:43:21 -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 36120-05 for ; Wed, 26 Nov 2008 08:43:18 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by mail.postgresql.org (Postfix) with ESMTP id 96E9364FED7 for ; Wed, 26 Nov 2008 08:43:18 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k40so1391939ugc.7 for ; Wed, 26 Nov 2008 04:43:16 -0800 (PST) Received: by 10.210.130.14 with SMTP id c14mr5902845ebd.190.1227703396315; Wed, 26 Nov 2008 04:43:16 -0800 (PST) Received: from ?80.222.79.63? (dsl-hkibrasgw2-fe4fde00-63.dhcp.inet.fi [80.222.79.63]) by mx.google.com with ESMTPS id c9sm142464nfi.26.2008.11.26.04.43.14 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 Nov 2008 04:43:14 -0800 (PST) Message-ID: <492D4460.1000809@enterprisedb.com> Date: Wed, 26 Nov 2008 14:43:12 +0200 Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) MIME-Version: 1.0 To: Tom Lane CC: PostgreSQL-development Subject: Re: Visibility map, partial vacuums References: <4905AE17.7090305@enterprisedb.com> <491D376B.9000608@enterprisedb.com> <491D7F52.6070908@enterprisedb.com> <4925664C.3090605@enterprisedb.com> <26361.1227467112@sss.pgh.pa.us> <492A6032.6080000@enterprisedb.com> <18086.1227537479@sss.pgh.pa.us> In-Reply-To: <18086.1227537479@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Heikki Linnakangas 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: 200811/1721 X-Sequence-Number: 128433 Tom Lane wrote: > Heikki Linnakangas writes: >> The visibility map won't be inquired unless you vacuum. This is a bit >> tricky. In vacuum, we only know whether we can set a bit or not, after >> we've acquired a cleanup lock on the page, and scanned all the tuples. >> While we're holding a cleanup lock, we don't want to do I/O, which could >> potentially block out other processes for a long time. So it's too late >> to extend the visibility map at that point. > > This is no good; I think you've made the wrong tradeoffs. In > particular, even though only vacuum *currently* uses the map, you want > to extend it to be used by indexscans. So it's going to uselessly > spring into being even without vacuums. > > I'm not convinced that I/O while holding cleanup lock is so bad that we > should break other aspects of the system to avoid it. However, if you > want to stick to that, how about > * vacuum page, possibly set its header bit > * release page lock (but not pin) > * if we need to set the bit, fetch the corresponding map page > (I/O might happen here) > * get share lock on heap page, then recheck its header bit; > if still set, set the map bit Yeah, could do that. There is another problem, though, if the map is frequently probed for pages that don't exist in the map, or the map doesn't exist at all. Currently, the size of the map file is kept in relcache, in the rd_vm_nblocks_cache variable. Whenever a page is accessed that's > rd_vm_nblocks_cache, smgrnblocks is called to see if the page exists, and rd_vm_nblocks_cache is updated. That means that every probe to a non-existing page causes an lseek(), which isn't free. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com