Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9tRT-0001lV-MJ for pgsql-committers@arkaria.postgresql.org; Fri, 29 Mar 2019 15:29:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h9tRS-0002Ds-8N for pgsql-committers@arkaria.postgresql.org; Fri, 29 Mar 2019 15:29:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9tRQ-0002AR-6A; Fri, 29 Mar 2019 15:29:14 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9tRN-0003X8-Jp; Fri, 29 Mar 2019 15:29:11 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id CA70522063; Fri, 29 Mar 2019 11:29:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 29 Mar 2019 11:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=AirEHFFzbWnUP9WuW6r/0GsvKnq Eky68sfuG3JNJKIk=; b=c9iqQBM3gt89MYHuAT75nWOu9LfYRDhagyN0MlGt4r7 26IVE7mWAs7bp27f563f/wnqlCPckYghwaO7vnzL2VJ/O1PKMSqJajYbFsEE3YYd lYaPMGFOXCUvgs0H22Y+J32VANUW2OwUAnPZfH/9JHW7Dn+VeycshaeY1VsWPQIK pNRI5unVatepNtB2Sbr8vfstEdooZ85a20CoKRf3v8/pNGZPmP3c8nu+YXcqKDyd 1KK6AFpxvfwhTxqR0f8cNWpssd+pkfqdq/A8cQBsavMnZGw+fHVlic/PrWP+V+nR 5XdKkm4HETcWYIzvUO2HVV7SGuAPeBkQfJJ2YXnjunw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=AirEHF FzbWnUP9WuW6r/0GsvKnqEky68sfuG3JNJKIk=; b=CfnMmxa/5F5iQPRoTNdwSh /7Od7ihIR6vVVfwEUP72R/4/m5I+xeKCJF6rlB1PVfF0jnUoLqmPHOpR60iTvumd PIaGq8WqncQ1wesPIOeT2GdX62EFEMjOwu5TAPdL0/FRLUjCGbyifq0/fnCgBAx8 +k5jTvY+khUqwhR7Kj4FVlH849XJv490F3wRS7cxi2OrT7bkOemsmGHaSFV1pRfq 9i5jQM6GKHdKyBQyA2a85WNaHhj4IDIb7FusqQR5JWy2+2gNFti8JOYceV5kC/Gv xCU6twsbEUAJl4NoRs4SKDx5otUIy4B0LRCnzj+wHITpCR0KCfOI8E1jHK/q5JIw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrkeejgdehtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecukfhppedvtd ekrdehgedrgeegrddvtddvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshes rghnrghrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (unknown [208.54.44.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 10DAA10392; Fri, 29 Mar 2019 11:29:08 -0400 (EDT) Date: Fri, 29 Mar 2019 08:29:06 -0700 From: Andres Freund To: Simon Riggs Cc: pgsql-committers , PostgreSQL Hackers Subject: Re: pgsql: Compute XID horizon for page level index vacuum on primary. Message-ID: <20190329152906.356icmttz7yjgsyh@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-03-29 09:37:11 +0000, Simon Riggs wrote: > This commit message was quite confusing. It took me a while to realize this > relates to btree index deletes and that what you mean is that we are > calculcating the latestRemovedXid for index entries. That is related to but > not same thing as the horizon itself. Well, it's the page level horizon... > While trying to understand this, I see there is an even better way to > optimize this. Since we are removing dead index tuples, we could alter the > killed index tuple interface so that it returns the xmax of the tuple being > marked as killed, rather than just a boolean to say it is dead. Wouldn't that quite possibly result in additional and unnecessary conflicts? Right now the page level horizon is computed whenever the page is actually reused, rather than when an item is marked as deleted. As it stands right now, the computed horizons are commonly very "old", because of that delay, leading to lower rates of conflicts. > Indexes can then mark the killed tuples with the xmax that killed them > rather than just a hint bit. This is possible since the index tuples > are dead and cannot be used to follow the htid to the heap, so the > htid is redundant and so the block number of the tid could be > overwritten with the xmax, zeroing the itemid. Each killed item we > mark with its xmax means one less heap fetch we need to perform when > we delete the page - it's possible we optimize that away completely by > doing this. That's far from a trivial feature imo. It seems quite possible that we'd end up with increased overhead, because the current logic can get away with only doing hint bit style writes - but would that be true if we started actually replacing the item pointers? Because I don't see any guarantee they couldn't cross a page boundary etc? So I think we'd need to do WAL logging during index searches, which seems prohibitively expensive. And I'm also doubtful it's worth it because: > Since this point of the code is clearly going to be a performance issue it > seems like something we should do now. I've tried quite a bit to find a workload where this matters, but after avoiding redundant buffer accesses by sorting, and prefetching I was unable to do so. What workload do you see where this would be really be bad? Without the performance optimization I'd found a very minor regression by trying to force the heap visits to happen in a pretty random order, but after sorting that went away. I'm sure it's possible to find a case on overloaded rotational disks where you'd find a small regression, but I don't think it'd be particularly bad. Greetings, Andres Freund