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 1vgafZ-00FqjB-2H for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jan 2026 03:38:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vgaeZ-000QfE-2H for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Jan 2026 03:37:40 +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 1vgaeZ-000Qf6-1I for pgsql-hackers@lists.postgresql.org; Fri, 16 Jan 2026 03:37:39 +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.96) (envelope-from ) id 1vgaeX-000kDV-1I for pgsql-hackers@postgresql.org; Fri, 16 Jan 2026 03:37:39 +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 60G3bSrq1004091; Thu, 15 Jan 2026 22:37:28 -0500 From: Tom Lane To: Richard Guo cc: PostgreSQL-development Subject: Re: Remove no-op PlaceHolderVars In-reply-to: References: <1346382.1725334280@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Fri, 16 Jan 2026 11:49:38 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1004089.1768534648.1@sss.pgh.pa.us> Date: Thu, 15 Jan 2026 22:37:28 -0500 Message-ID: <1004090.1768534648@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > While fixing some performance issues caused by PHVs recently, it > struck me again that we should be removing "no-op" PHVs whenever > possible, because PHVs can be optimization barriers in several cases. My immediate reaction is "how sure are you that they're no-ops"? I recall that there are places where we intentionally insert PHVs to preserve the separate identity of the contained expression (so that, for example, it can be matched to a subquery output later). > I still do not have a good idea for ensuring that removing the PHV > wrapper does not break the expression tree invariants. But maybe we > can use a conservative approach: we only strip the PHV if the > contained expression is known to be safe (for example, a simple Var). Do we generate a PHV at all in that case? Seems like we could deal with that by adding to the Var's varnullingrels instead of making a wrapper node. regards, tom lane