Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v6xxC-00ChKN-1u for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Oct 2025 21:13:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v6xx9-008f41-On for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Oct 2025 21:13:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v6xx9-008f3p-Dl for pgsql-hackers@lists.postgresql.org; Thu, 09 Oct 2025 21:13:36 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v6xx6-000vU8-2s for pgsql-hackers@postgresql.org; Thu, 09 Oct 2025 21:13:35 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 762B9EC028C; Thu, 9 Oct 2025 17:13:33 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 09 Oct 2025 17:13:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1760044413; x=1760130813; bh=GCfKayk1wMXg6Xr1IzDU8LfoVkzA3lB4Vio+QnnV6I8=; b= riXyDCU7oj3Vqrle7CB/DnrlgTqGC1Ro6Y/iwtif/+mscROIfhAiFF+8nicn1VCi ei2YodZ4CuvC0C1tvUngH4iZicS2U9WB2sOEFp8uLMtQIFLHARcXmBZZFjeMtTUw tlpn5zD8QpPy8UCAA4UBTew6zY1jydINZqSe271RdveMloY9Ma3GCsOmwTHn+eLx et+9gOiB8NvNCfEjUoRSFho5bqJYGJywlAiJ7kPiFWs87kwHHJKVZM/A5co6+xmx Lexq6st6Fmrhyt6y9or366UGMeJDPQ4f2fpuquSQaHsd8hWxq2ulXfGPrcBZPGbP MBCnA77/gUO65TJDT9ZkYg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1760044413; x= 1760130813; bh=GCfKayk1wMXg6Xr1IzDU8LfoVkzA3lB4Vio+QnnV6I8=; b=q W5d4RA1WHlHA+DkSuNFLggeaX9WQaNWbXFvotMU03SWffWar/cF9tbvqBdTkfmWW zE/FULwhRWBSCDCJqzSTYyh6TorpVZ3JhKWGz3Ry5MsL8aLQG1omPzhQ9+atGjGo TBmGtWeScvA4F11fzTdD1TgYoph8DePNF8gcCISXaMZhIkOqL2ADMxa1q4nIdB8y zpZ//aXBWCHOGLNjBzL2G6W2nK0l5GZlgnJbPDhwZ1NtnebZ5nE390VhyAGj4dPc lpOwozxASUE9jOVufKRmWAZsGMETSh4Brl1B8FUuQaXB0fx43BdGsxzyjcFIubn2 UO7iywqzJwfmv9o4NpuXg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddutdejvddvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurheptggguffhjgffvefgkfhfvffosehtqhhmtdhhtdejnecuhfhrohhmpefirhgvghcu uehurhguuceoghhrvghgsegsuhhrugdrmhgvqeenucggtffrrghtthgvrhhnpeeiuddvvd eiieejiedvtefhhfetvefhveelffevvedtudegueekudeltdevteejheenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehgrhgvghessghurhgurd hmvgdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohep phhgshhqlhesjhdquggrvhhishdrtghomhdprhgtphhtthhopehnrghthhgrnhgusghosh hsrghrthesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhs sehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Oct 2025 17:13:33 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: Expanding HOT updates for expression and partial indexes From: Greg Burd In-Reply-To: <96b451774d927daffe7fe40d06447eabb06a8f3f.camel@j-davis.com> Date: Thu, 9 Oct 2025 17:13:12 -0400 Cc: Nathan Bossart , "pgsql-hackers@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <97f0aa72-f172-4673-8b04-533f022c3149@app.fastmail.com> <96b451774d927daffe7fe40d06447eabb06a8f3f.camel@j-davis.com> To: Jeff Davis X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Oct 9, 2025, at 3:08=E2=80=AFPM, Jeff Davis = wrote: >=20 > On Wed, 2025-10-08 at 15:48 -0500, Nathan Bossart wrote: >>> The theory being that >>> my new code using the old/new tts to form and test the index tuples >>> resulting from executing expressions was using the resultsRelInfo >>> struct >>> created during plan execution, not the information found on the >>> page, >>> and so was safe without the lock. >>=20 >> An open question (at least from me) is whether this is safe. I'm not >> familiar enough with this area of code yet to confidently determine >> that. Hey Jeff, Thanks for the nudge at PGConf.dev in NYC and for the follow-up here. > The optimization requires that the expression evaluates to the same > thing on the old and new tuples. That determination doesn't have > anything to do with a lock on the buffer, so long as the old tuple > isn't pruned away or something. And clearly it won't be pruned, = because > we're in the process of updating it, so we have a snapshot that can = see > it. Right, I test that the expression on the index evaluates to the same value when forming an index tuple for old/new slots. > There might be subtleties in other parts of the proposal, but the = above > determination can be made safely without a buffer lock. >=20 >>=20 >>> I added a reloption "expression_checks" to disable this new code >>> path.=20 >>> Good idea or bad precedent? >>=20 >> If there are cases where the added overhead outweighs the benefits >> (which >> seems like it must be true some of the time), then I think we must >> have a >> way to opt-out (or maybe even opt-in). In fact, I'd advise adding a >> GUC to >> complement the reloption so that users can configure it at higher >> levels. >=20 > I'll push back against this. For now I'm fine with developer options = to > make testing easier, but we should find a way to make this work well > without tuning. I'm aligned with this, the reloption evolved from a GUC and I'm more of the opinion that neither should exist and that the overhead of this be minimized and so require no tuning or consideration by the end user. best. -greg > Regards, > Jeff Davis