Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VM4QB-00025g-L5 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Sep 2013 23:11:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VM4QA-0002Ho-Sb for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Sep 2013 23:11:02 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VM4Q9-0002Hf-CV for pgsql-hackers@postgresql.org; Tue, 17 Sep 2013 23:11:01 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VM4Q5-00030s-IQ for pgsql-hackers@postgresql.org; Tue, 17 Sep 2013 23:11:00 +0000 Received: from anarazel.de (p5DDC4CBE.dip0.t-ipconnect.de [93.220.76.190]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0MG40o-1VAVgb119C-00Ethl; Wed, 18 Sep 2013 01:10:51 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 98807100D8A; Wed, 18 Sep 2013 01:10:50 +0200 (CEST) Date: Wed, 18 Sep 2013 01:10:50 +0200 From: Andres Freund To: Jim Nasby Cc: Bruce Momjian , Alvaro Herrera , Robert Haas , Peter Geoghegan , Tom Lane , Andrew Dunstan , PostgreSQL-development Subject: Re: [PERFORM] encouraging index-only scans Message-ID: <20130917231050.GD29545@awork2.anarazel.de> References: <20130906052236.GF6067@eldon.alvh.no-ip.org> <20130906130854.GB600952@alap2.anarazel.de> <20130906163056.GA13158@momjian.us> <20130906163647.GA626072@alap2.anarazel.de> <20130906170159.GB13158@momjian.us> <20130906191330.GA13193@momjian.us> <20130906222623.GC626072@alap2.anarazel.de> <20130907002908.GA12753@momjian.us> <20130907053449.GE626072@alap2.anarazel.de> <5238854F.5040708@nasby.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5238854F.5040708@nasby.net> X-Provags-ID: V02:K0:WuGyS9I8oiJRDl9m1bSgD0I3Dj2AmlRP11RS7d5dlhM zJ/bokH3K4dqZo9S7/wQ+o66OaZZuEshWoEbotwHYZPrBh81e9 zSXRxJWaS1JCY6DOyXZ8PZqWaLf0PhtYsCN0OnQQc4COmy1oeS A3m032hMRxDcSRXxEeJ09wUJStSi6T8/yrDCp6/ItvUmgoNyNJ QcQ1/NBIYMwvLDeYT3HHiBF6aMdnzPf9OtoOYtSfxUCXKipj+T 608GS1jeSuttTjLhkaZYy3nKPZcYW6A88f42FAoigK2GqbQLXQ t26l/3fYTMK4YHxVCRXVAEg00vHAU2vDTCgnjRtXTZwU4T+T28 CGu9pKbEWsSfD8ayXN69Ga14kzkizlt0MEzJBmJRj X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2013-09-17 11:37:35 -0500, Jim Nasby wrote: > On 9/7/13 12:34 AM, Andres Freund wrote: > >What I was thinking of was to keep track of the oldest xids on pages > >that cannot be marked all visible. I haven't thought about the > >statistics part much, but what if we binned the space between > >[RecentGlobalXmin, ->nextXid) into 10 bins and counted the number of > >pages falling into each bin. Then after the vacuum finished we could > >compute how far RecentGlobalXmin would have to progress to make another > >vacuum worthwile by counting the number of pages from the lowest bin > >upwards and use the bin's upper limit as the triggering xid. > > > >Now, we'd definitely need to amend that scheme by something that handles > >pages that are newly written to, but it seems something like that > >wouldn't be too hard to implement and would make autovacuum more useful. > > If we're binning by XID though you're still dependent on scanning to > build that range. Anything that creates dead tuples will also be be > problematic, because it's going to unset VM bits on you, and you won't > know if it's due to INSERTS or dead tuples. I don't think that's all that much of a problem. In the end, it's a good idea to look at pages shortly after they have been filled/been touched. Setting hint bits at that point avoid repetitive IO and in many cases we will already be able to mark them all-visible. The binning idea was really about sensibly estimating whether a new scan already makes sense which is currently very hard to judge. I generally think the current logic for triggering VACUUMs via autovacuum doesn't really make all that much sense in the days where we have the visibility map. > What if we maintained XID stats for ranges of pages in a separate > fork? Call it the XidStats fork. Presumably the interesting pieces > would be min(xmin) and max(xmax) for pages that aren't all visible. If > we did that at a granularity of, say, 1MB worth of pages[1] we're > talking 8 bytes per MB, or 1 XidStats page per GB of heap. (Worst case > alignment bumps that up to 2 XidStats pages per GB of heap.) Yes, I have thought about similar ideas as well, but I came to the conclusion that it's not worth it. If you want to make the boundaries precise and the xidstats fork small, you're introducing new contention points because every DML will need to make sure it's correct. Also, the amount of code that would require seems to be bigger than justified by the increase of precision when to vacuum. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers