Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxDYf-0003Vx-EZ for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Dec 2021 19:33:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxDYd-0004VX-VS for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Dec 2021 19:33:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxDYd-0004VO-NR for pgsql-bugs@lists.postgresql.org; Tue, 14 Dec 2021 19:33:51 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxDYb-0005JQ-Ct for pgsql-bugs@lists.postgresql.org; Tue, 14 Dec 2021 19:33:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1BEJXluD377325; Tue, 14 Dec 2021 14:33:47 -0500 From: Tom Lane To: Peter Geoghegan cc: Klaudie Willis , PostgreSQL mailing lists Subject: Re: When Update balloons memory In-reply-to: References: <3484560.1638889073@sss.pgh.pa.us> <189763.1639437451@sss.pgh.pa.us> <261065.1639497535@sss.pgh.pa.us> Comments: In-reply-to Peter Geoghegan message dated "Tue, 14 Dec 2021 11:21:54 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <377323.1639510426.1@sss.pgh.pa.us> Date: Tue, 14 Dec 2021 14:33:47 -0500 Message-ID: <377324.1639510427@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Geoghegan writes: > Are you sure that it would really be worth the trouble of caching our > answer? It's not clear that that has only minimal maintenance burden. I'd be inclined to do so if we can find a suitable place to put it. But wouldn't a field in IndexInfo serve? Letting the field default to "not optimizable" would cover most cases. > The fact is that most individual aminsert() calls that get the hint > will never actually apply it in any way. Yeah, you could make an argument that just not trying to optimize when there are index expressions would be fine for this --- and we may have to fix it that way in v14, because I'm not sure whether adding a field in IndexInfo would be safe ABI-wise. But ISTM that the overhead of index_unchanged_by_update is a bit more than I care to pay per row even when it's only considering plain index columns. I'm generally allergic to useless per-row computations, especially when they're being added by an alleged performance improvement. Another thing we ought to check into is the extent to which this is duplicative of the setup calculations for HOT updates --- I seem to recall that there's already roughly-similar logic somewhere else. And, not to be too picky, but does this cope with the case where an indexed column is changed by a BEFORE trigger, not by the query proper? regards, tom lane