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 1w4kD4-002Vo6-1z for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 18:41:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4kC2-001bhR-0p for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 18:40:02 +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.96) (envelope-from ) id 1w4kC1-001bhI-2U for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 18:40:02 +0000 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4kC0-00000000fMm-13NK for pgsql-hackers@postgresql.org; Mon, 23 Mar 2026 18:40:01 +0000 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-45f053b7b90so285752b6e.0 for ; Mon, 23 Mar 2026 11:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774291199; x=1774895999; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dl/l5FtH5f68dewe+4iTOjHmN+863pJ6sM61DH8/INg=; b=fPx64NNZs0uvvejbxgVlw9lCHzVCuhLkGoTlTtU9Fmbb7YQHDUxaG9IHO/1f7DH9Y3 Z2XF80vnz23Ivman7w5nGXq1R0n/MGMFL/jm1h2mk6JtXfEn4E+ipnYqAp1KKS0S095g XHDDOzSZRKf5Nbb61+ejT5DcZopAW/PQXVpq4msd7gsEwiWRmdi17Y5cy54Z8mN+/xNZ A4oGUpc9WPYCG1LfqAQKAUbO4KMqnxxWdGBFTJEydUyn0HIREkge0E9eGJTRGZ3S2cP0 Pks+XCWnpYmeXAVFQ3aSSJ/nsRIKfQXQcggWCgdeAi9baQ3HUxzC2BSquhv59+uyWPqs sWJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774291199; x=1774895999; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dl/l5FtH5f68dewe+4iTOjHmN+863pJ6sM61DH8/INg=; b=WnKlnAwrhI2smioVptZtdNnT7EjM12aYE7liE88W99nLPPrf/2bHNnmsdiIbHcqOkh movYBc7jfM3xwq7BqNEPxlXA0qWpgvaX2IK+Agub9IaPGfDXBiTuP0pqkBoXMpIXr6c5 /vLFx2NpMdSXdwbUsODezraHQpoTBllJdPJrk+xQxKoWBVZk6VcLP497sXau4R1y6DRl AKKvLCBMqt9jErvAEbMbpQyDo1nBQgecZejCdE5fB/orguBfdkFCdxiLLjHirxfMvis6 mhgmnwnbRCC3UFqL2jn9NEWUcW1WcjCDQDXNDigI5pxjH4amz8Xnby7khGR+tZ0awSQC rrsw== X-Forwarded-Encrypted: i=1; AJvYcCUCPk0GzQwwh15CAmkUT/psXEAKp0+33t1yc7TuIn4tVX6q+aLpFsOF1hXliSqyK+uwcFU3W12ifE/qsq6M@postgresql.org X-Gm-Message-State: AOJu0Yx+oQhVMOt8dZjI/khGJRh3MoFCdigZiQeiqK8mFzKFI8JSQtnB +vshOMG85Z79dSV2IBgjHznemHDBDQDueiLFJaqfD7mudM9lb77NQwcfx0JbRg== X-Gm-Gg: ATEYQzx7HPi6dt9K1XzdxngArXhK84I3MULkFuv/Y/Hk7sBpZR4AABxf+WGl0m4HnR7 KBFE0/5XcJgWNz5mzcMyrCDcPX1jvkByroQfS3/1Ux2AwgTLZK3UgZhKrd6VzmZ3jU5IldkGYb+ kgWnKYbW9ZQgALfKSFvWJP3Xp+ITECAl6LTmUVfWC9MXhqOvP/r74BtlDKT5QP8TOXUBL6nMZXq CAhPsZvLY8F62lI9wzRNssQeYg/sLianrv+EeEtNDUjBSsPZ8wqdpNMjlVUXz8uYNmwxpjgwWSr P81BDKkIB5Aaui98PaAtt+HgGpn9t3+SEHCdiB942roKYqfDcYgXayZ+tfNP5S5e3iSMJSwqONj k4xbh5/9fnVZy8zXG91P47RiJ/bUNjAKTyNmUWZQn/ucBb6H0NIo9V/Jl/6BTFlHxbrSL9vin3W CcK8rHV4Ki2XDY+kLqtfMzV8gDh3G4rRGfyegcRuaQgkL0OMLo7ynunnKSbIM82MJdILcj8RNxf JsAldVdYQ0Qz6aDznL4ew== X-Received: by 2002:a05:6808:8957:b0:467:15dc:b32a with SMTP id 5614622812f47-467e5f22652mr8066712b6e.42.1774291199192; Mon, 23 Mar 2026 11:39:59 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-41c148a5f99sm11401065fac.2.2026.03.23.11.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 11:39:57 -0700 (PDT) Date: Mon, 23 Mar 2026 13:39:55 -0500 From: Nathan Bossart To: Greg Burd Cc: Jeff Davis , pgsql-hackers Subject: Re: Expanding HOT updates for expression and partial indexes Message-ID: References: <91f4dbe2-21ed-49f3-bebe-270f9bbec9d5@app.fastmail.com> <811d6f42e5481935943556b692859aae9146d4c9.camel@j-davis.com> <7b8681a578b5fe77103948eeb7b5cdd80fabad5d.camel@j-davis.com> <4f48f75d-4f2a-4240-b66d-597517796e02@app.fastmail.com> <3fba3f5671eddb221ba38f5a12acbe7cad27edf3.camel@j-davis.com> <427bfbda-c901-49e4-b725-8ddc41bec23d@app.fastmail.com> <887b1ee62794553a95c3578fcdc0cc1831e68b27.camel@j-davis.com> 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: Archived-At: Precedence: bulk Thanks for the new patch. As a general note, please be sure to run pgindent on patches. My review is still rather surface-level, sorry. On Tue, Mar 17, 2026 at 02:04:11PM -0400, Greg Burd wrote: > - id_attrs = RelationGetIndexAttrBitmap(relation, > - INDEX_ATTR_BITMAP_IDENTITY_KEY); > [...] > + rid_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_IDENTITY_KEY); I'm nitpicking, but it took me a while to parse the replica-identity-related code in heap_update() until I discovered that this variable was renamed. I think we ought to leave the name alone. > /* > * At this point newbuf and buffer are both pinned and locked, and newbuf > - * has enough space for the new tuple. If they are the same buffer, only > - * one pin is held. > + * has enough space for the new tuple so we can use the HOT update path if > + * the caller determined that it is allowable. > + * > + * NOTE: If newbuf == buffer then only one pin is held. > */ > - > if (newbuf == buffer) Sorry, more nitpicks. In addition to the unnecessary removal of the blank line, I'm not sure the changes to this comment are needed. > - /* > - * If it is a HOT update, the update may still need to update summarized > - * indexes, lest we fail to update those summaries and get incorrect > - * results (for example, minmax bounds of the block may change with this > - * update). > - */ > - if (use_hot_update) > - { > - if (summarized_update) > - *update_indexes = TU_Summarizing; > - else > - *update_indexes = TU_None; > - } > - else > - *update_indexes = TU_All; So, the "HOT but still need to update summarized indexes" code has been moved from heap_update() to HeapUpdateHotAllowable(), which is called by heap_update()'s callers (i.e., simple_heap_update() and heapam_tuple_update()). That looks correct to me at a glance. > -simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tup, > +simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tuple, nitpick: This variable name change looks unnecessary. > @@ -944,8 +946,13 @@ ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo, > if (rel->rd_rel->relispartition) > ExecPartitionCheck(resultRelInfo, slot, estate, true); > > + modified_idx_attrs = ExecUpdateModifiedIdxAttrs(resultRelInfo, > + estate, searchslot, slot); > + > simple_table_tuple_update(rel, tid, slot, estate->es_snapshot, > - &update_indexes); > + modified_idx_attrs, &update_indexes); > + bms_free(modified_idx_attrs); I don't know how constructive of a comment this is, but this change in particular seems quite out of place. It feels odd to me that we expect callers of simple_table_tuple_update() to determine the modified-index-attributes. I guess I'm confused why this work doesn't belong one level down, i.e., in the tuple_update function. > - * INDEX_ATTR_BITMAP_SUMMARIZED Columns included in summarizing indexes > + * INDEX_ATTR_BITMAP_INDEXED Columns referenced by indexes > + * INDEX_ATTR_BITMAP_SUMMARIZED Columns only included in summarizing indexes > - Bitmapset *summarizedattrs; /* columns with summarizing indexes */ > + Bitmapset *indexedattrs; /* columns referenced by indexes */ > + Bitmapset *summarizedattrs; /* columns only in summarizing indexes */ As before, the comment changes for the summarized-attr-related stuff seem unnecessary. > if (indexDesc->rd_indam->amsummarizing) > attrs = &summarizedattrs; > else > - attrs = &hotblockingattrs; > + attrs = &indexedattrs; > + /* > + * Record what attributes are only referenced by summarizing indexes. Then > + * add that into the other indexed attributes to track all referenced > + * attributes. > + */ > + summarizedattrs = bms_del_members(summarizedattrs, indexedattrs); > + indexedattrs = bms_add_members(indexedattrs, summarizedattrs); The difference between hotblockingattrs and indexedattrs seems quite subtle. Am I understanding correctly that indexedattrs is essentially just hotblockingattrs + summarizedattrs? And that this is all meant for INDEX_ATTR_BITMAP_INDEXED? - INJECTION_POINT("heap_update-before-pin", NULL); + INJECTION_POINT("simple_heap_update-before-pin", NULL); Why was this changed in heap_update()? -- nathan