Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D1A1464FFE0 for ; Thu, 27 Nov 2008 15:44:23 -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 48865-02 for ; Thu, 27 Nov 2008 15:44:21 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by mail.postgresql.org (Postfix) with ESMTP id 0ED1564FEBB for ; Thu, 27 Nov 2008 15:44:20 -0400 (AST) Received: by ey-out-2122.google.com with SMTP id 6so488807eyi.61 for ; Thu, 27 Nov 2008 11:44:19 -0800 (PST) Received: by 10.210.117.1 with SMTP id p1mr2286677ebc.82.1227815059536; Thu, 27 Nov 2008 11:44:19 -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 f6sm1856420nfh.12.2008.11.27.11.44.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Nov 2008 11:44:18 -0800 (PST) Message-ID: <492EF88F.9050709@enterprisedb.com> Date: Thu, 27 Nov 2008 21:44:15 +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> <492D4460.1000809@enterprisedb.com> <5856.1227705135@sss.pgh.pa.us> In-Reply-To: <5856.1227705135@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/1831 X-Sequence-Number: 128543 Tom Lane wrote: > Heikki Linnakangas writes: >> 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. > > Well, considering how seldom new pages will be added to the visibility > map, it seems to me we could afford to send out a relcache inval event > when that happens. Then rd_vm_nblocks_cache could be treated as > trustworthy. Here's an updated version, with a lot of smaller cleanups, and using relcache invalidation to notify other backends when the visibility map fork is extended. I already committed the change to FSM to do the same. I'm feeling quite satisfied to commit this patch early next week. I modified the VACUUM VERBOSE output slightly, to print the number of pages scanned. The added part emphasized below: postgres=# vacuum verbose foo; INFO: vacuuming "public.foo" INFO: "foo": removed 230 row versions in 10 pages INFO: "foo": found 230 removable, 10 nonremovable row versions in *10 out of* 43 pages DETAIL: 0 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 0.00s/0.00u sec elapsed 0.00 sec. VACUUM That seems OK to me, but maybe others have an opinion on that? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com