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 1rT3RQ-00060W-Ng for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2024 17:23:05 +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 1rT3RP-001lOB-TL for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jan 2024 17:23:03 +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.94.2) (envelope-from ) id 1rT3RP-001lLH-Jz for pgsql-hackers@lists.postgresql.org; Thu, 25 Jan 2024 17:23:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rT3RN-003gX3-4Z for pgsql-hackers@postgresql.org; Thu, 25 Jan 2024 17:23:03 +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 40PHMxLi412553; Thu, 25 Jan 2024 12:22:59 -0500 From: Tom Lane To: David Rowley cc: Richard Guo , PostgreSQL-development Subject: Re: A performance issue with Memoize In-reply-to: References: Comments: In-reply-to David Rowley message dated "Thu, 25 Jan 2024 13:13:41 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <412551.1706203379.1@sss.pgh.pa.us> Date: Thu, 25 Jan 2024 12:22:59 -0500 Message-ID: <412552.1706203379@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I'd feel better about doing it your way if Tom could comment on if > there was a reason he put the function calls that way around in > 5ebaaa494. Apologies for not having noticed this thread before. I'm taking a look at it now. However, while sniffing around this I found what seems like an oversight in paramassign.c's assign_param_for_var(): it says it should compare all the same fields as _equalVar except for varlevelsup, but it's failing to compare varnullingrels. Is that a bug? It's conceivable that it's not possible to get here with varnullingrels different and all else the same, but I don't feel good about that proposition. I tried adding @@ -91,7 +91,10 @@ assign_param_for_var(PlannerInfo *root, Var *var) pvar->vartype == var->vartype && pvar->vartypmod == var->vartypmod && pvar->varcollid == var->varcollid) + { + Assert(bms_equal(pvar->varnullingrels, var->varnullingrels)); return pitem->paramId; + } } } This triggers no failures in the regression tests, but we know how little that proves. Anyway, that's just a side observation unrelated to the problem at hand. More later. regards, tom lane