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.96) (envelope-from ) id 1vs4Pj-0047hA-3A for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 19:37:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vs4Oh-005D3n-23 for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 19:36:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vs4Oh-005D3d-0Y for pgsql-hackers@lists.postgresql.org; Mon, 16 Feb 2026 19:36:43 +0000 Received: from mail-dl1-x122a.google.com ([2607:f8b0:4864:20::122a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vs4Oe-000000014bT-3AeS for pgsql-hackers@postgresql.org; Mon, 16 Feb 2026 19:36:42 +0000 Received: by mail-dl1-x122a.google.com with SMTP id a92af1059eb24-12732e6a123so4021169c88.1 for ; Mon, 16 Feb 2026 11:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1771270598; x=1771875398; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=+5CYc4KXOg6NsqCC9axKtf/SXW5bzs+vaY1Fo+vLV74=; b=J/3scKZtBp7Z1XrIzsKIZJU2lNCiKpNPDbfffdY2pr30jk5xmpONiRfofKvDT0cYGl KnGoxFzYoSAr+PfoOZgoKFZLmfxkQrAZeocxl4H8ctlxENH8umH+ZTsQq3hZkTsSNtua LaX9oTuNeMN5fkQ00fPMc/YDaBeGKORFPKm8hZbzAabJuoamiohdcCsuup7vidNjvMFE rPuUKjNqD4jY0qdvc/9yHasH0NWA2Itb9ROZelK4hCS7010Yov2rl7lGZ2T12P7Y/l0Z DxxZpxcLNOa3zQp4yDKzHFGEr8bSL3cWtY3gSAUxUP3A9elgUVRg/coo8cCtPgUEt8DF uZ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771270598; x=1771875398; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+5CYc4KXOg6NsqCC9axKtf/SXW5bzs+vaY1Fo+vLV74=; b=qupq9fpmsn7QcWV0LY+8CKGtBkMLy4V4HVQliyeUkWcr+DH77FLuvNoXqWAtPNmyca ELwEh2b1oCw8ZcxsReVq6kTnUqgxN0hI+hL00raq4IVY49qT58oad/UZ2pBZjp6wzoMB LB5Is3a9RNNvY+XkWIqlSSjI59nUu0zNgJdWAJDwSmwaGoaTb5IKMZBJlugdm3Pt14HS sYNlmOH8V8gnO8odVePX4Tjy/UNAsZlyjciTnVz9ZaPTe0UVlT87tFo000v+HBrvTZxu pTpH3cOPcoENVKvU/NCF6dleaBo7DSLyQnKcugBft07xFfUQ38T9kFOXT6btgJReWxLi lgkQ== X-Forwarded-Encrypted: i=1; AJvYcCVCrrXx+P2JNd1uW09drFAHDlKlNdvCQCf4nkNqcWzYzdjxOi569Nyo9A+BEymQ2xRkzOQmTKa7tTTeKLxM@postgresql.org X-Gm-Message-State: AOJu0YxgmDtYI9tTgtLEtxaeMggsAdm+u8im2QMNwH4f+Rcqg8gbaxPI MzQFva86so70ryIkoyiNoXuayteh4ySvjSb+6h4Vn+sf6EcwI8vKw2EbJZjeYSbiI4IIvQFzPz2 i1Ts= X-Gm-Gg: AZuq6aJJIGjtXjHYdc6CZJVfV1k16whQ2qPRKRcWhQ7rCONM8ctRGcBmn/oOb9QVdni j8acNqu2M49f0sjywPPlvzYEuzfnpJv1FOOO5Hm+nOAFgEEDe/hSq0iPK9EwXuMANSg7plsUKJ8 qsmK1dvJE3r4uNFb3OK7QyeMdqbSnRpblfJpJ4Rhl8PQzS7m70JT45dgrj7TKKn68UlDXP0SQqa /Ge7ju1M6pIHVZn5fG6Dxmvnj6FHChIrCtxoZYtu1mLVNBzcZM6CiNOO6+g5kLlUxBnKFnQRKv9 aWlGtwhCbKL8fjXMoSzhVu+PfKZG8FQlN/SvcYSEOBjJIstp0HmmaIiakkvkf//DY7+RlW4otEg vH5Kh0HLzvJU/DFUmUTJ9a6I+WLbjsHAo0NRbUBDd1MtAOcxFrAuFT6dqz52fWnwsJTANLIRtQW TzpPmkDr4CzSgcluhFLbRCcsedv8g4HAanoZdLAOxYMXdLic2o4v0= X-Received: by 2002:a05:7022:4186:b0:121:dea2:d54d with SMTP id a92af1059eb24-1273ade42f9mr5451807c88.20.1771270597816; Mon, 16 Feb 2026 11:36:37 -0800 (PST) Received: from jeff-laptop.lan (c-24-7-19-3.hsd1.ca.comcast.net. [24.7.19.3]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bacb67bc16sm11388981eec.32.2026.02.16.11.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Feb 2026 11:36:37 -0800 (PST) Message-ID: Subject: Re: Expanding HOT updates for expression and partial indexes From: Jeff Davis To: Greg Burd , pgsql-hackers Date: Mon, 16 Feb 2026 11:36:36 -0800 In-Reply-To: References: <5165C147-B476-4E3D-AAA9-11C0B966FC4D@greg.burd.me> <9394564A-5764-4DCA-8845-8AE102DE61DC@greg.burd.me> <97769442-2ed7-4fe0-a393-7e2b5ff7ff58@app.fastmail.com> <3e1b9075c92808a7356e79087ba51910e5db5a30.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3-0ubuntu1.1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2026-02-15 at 15:39 -0500, Greg Burd wrote: > (2) Types don't influence this decision today.=C2=A0 Their equality > operators are not used, attributes are memcmp().=C2=A0 This is a > requirement for index-only scans.=C2=A0 I think it's insufficient for > types like JSONB which have internal structure that can be extracted > to form index keys, but that's for a later commit. That's an interesting path but would require more infrastructure, and to justify going down that path we should look for other opportunities to use that type infra beyond just HOT. Brainstorming: maybe something in the planner can make use of intelligence around expressions that are effectively setter/accessor methods on complex types? (Obviously work for later.) > I can see how this might be confusing, you're asking a good > question.=C2=A0 Why not just add the mix_attrs as an argument to the tabl= e > AM update call and be done? >=20 > 1. Bitmapsets that are NULL mean empty, so how would > simple_heap_update() signal to heap_update() that it needs to > determine the modified indexed attributes?=C2=A0 We'd have to add a bool > along with the mix_attrs Bitmapset to indicate: "we've not calculated > the set yet, you need to do that." Maybe an extra bool is not ideal, but it's better than moving code onto the wrong side of an API boundary. > 2. After fetching the exclusive buffer lock there is the test > `!ItemIdIsNormal(lp)` to cover the case where a simple_heap_update() > the otid origin is the syscache, there is no pin or snapshot, and so > there might be LP_* states other than LP_NORMAL due to concurrent > pruning.=C2=A0 This only happens when updating catalog tuples, so this > logic need not be present at all in the heapam_tuple_update().=C2=A0 Yes, > the if() branch will be fast (frequently predicted by the CPU) but > this feels like logic specific to the update of catalog tuples. If convenient I'm fine with moving that branch out, but I think it needs to be done with the buffer locked (right?), so heap_update() looks like the right place for that test for now. > 3. HeapDetermineColumnsInfo() actually does more than find the > modified indexed attributes, it also performs half of the check for > the requirement to WAL log the replica identity attributes.=C2=A0 The > replacement function in the executor doesn't do this work, so that is > coded into heapam_tuple_update() but not simple_heap_update().=C2=A0 The > second half is in ExtractReplicaIdentity() that happens later in the > heap_update() function after determining if HOT is a possibility or > not. IIUC you are saying that the decision is too heap-specific to expose to the executor. I think that's true today (as ExtractReplicaIdentity() is in heapam.c), but perhaps that's not fundamental: TOAST is not heap- specific, replica IDs are not heap-specific, and if you are WAL-logging a replica identity key it seems like you need to know whether it's external or not regardless of the AM. I'm not asking for a change here, just trying to understand the API boundaries. > I have moved these changes back into heap_update(), add the mix_attrs > and mix_attrs_valid to see how things look, that's the attached > patch. Thank you -- that's easier to understand. Why does simple_heap_update() need to do the HeapDetermineColumnsInfo() inside heap_update()? It seems like you're trying to avoid doing the same work the executor is doing to determine the modified_attrs bitmap, but either (a) the work is cheap; or (b) the work to make the bitmap is expensive. If (a), then just construct the correct bitmap in simple_heap_update() and simplify the code. If (b), then optimizing the simple_heap_update() case isn't good enough, we need to find ways of avoiding the work in the most common cases in the executor, as well. Regards, Jeff Davis