Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WDGsi-0000Af-VI for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2014 17:12:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WDGsi-0006Qq-Fl for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Feb 2014 17:12:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WDGsh-0006Qi-Fr for pgsql-hackers@postgresql.org; Tue, 11 Feb 2014 17:12:23 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WDGse-0004JT-Mo for pgsql-hackers@postgresql.org; Tue, 11 Feb 2014 17:12:23 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1WDGsX-0006oL-Tz; Tue, 11 Feb 2014 12:12:13 -0500 Date: Tue, 11 Feb 2014 12:12:13 -0500 From: Bruce Momjian To: Robert Haas Cc: Andres Freund , Jim Nasby , Alvaro Herrera , Peter Geoghegan , Tom Lane , Andrew Dunstan , PostgreSQL-development Subject: Re: [PERFORM] encouraging index-only scans Message-ID: <20140211171213.GE2289@momjian.us> References: <20130906222623.GC626072@alap2.anarazel.de> <20130907002908.GA12753@momjian.us> <20130907053449.GE626072@alap2.anarazel.de> <5238854F.5040708@nasby.net> <20130917231050.GD29545@awork2.anarazel.de> <20140201032207.GD31141@momjian.us> <20140211155607.GB2289@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.6 (--) 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 Tue, Feb 11, 2014 at 11:28:36AM -0500, Robert Haas wrote: > A sequential scan will set hint bits and will prune the page, but > pruning the page doesn't ever mark it all-visible; that logic is > entirely in vacuum. If that could be made cheap enough to be > negligible, it might well be worth doing in heap_page_prune(). I > think there might be a way to do that, but it's a bit tricky because > the pruning logic iterates over the page in a somewhat complex way, > not just a straightforward scan of all the item pointers the way the > existing logic doesn't. It would be pretty cool if we could just use > a bit out of the heap-prune xlog record to indicate whether the > all-visible bit should be set; then we'd gain the benefit of marking > things all-visible much more often without needing vacuum. > > That doesn't help insert-only tables much, though, because those won't > require pruning. We set hint bits (which dirties the page) but > currently don't write WAL. We'd have to change that to set the > all-visible bit when scanning such a table, and that would be > expensive. :-( Yes, that pretty much sums it up. We introduced index-only scans in 9.2 (2012) but they still seem to be not usable for insert-only workloads two years later. Based on current progress, it doesn't look like this will be corrected until 9.5 (2015). I am kind of confused why this has not generated more urgency. I guess my question is what approach do we want to take to fixing this? If we are doing pruning, aren't we emitting WAL? You are right that for an insert-only workload, we aren't going to prune, but if pruning WAL overhead is acceptable for a sequential scan, isn't index-only page-all-visible WAL overhead acceptable? Do we want to track the number of inserts in statistics and trigger an auto-vacuum after a specified number of inserts? The problem there is that we really don't need to do any index cleanup, which is what vacuum typically does --- we just want to scan the table and set the all-visible bits, so that approach seems non-optimal. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers