public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Richard Guo <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: Remove no-op PlaceHolderVars
Date: Thu, 15 Jan 2026 22:37:28 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAMbWs4-_fDPOiYJWj330pJS++kKbTw_EfO5-pC8nPKHUAScMWw@mail.gmail.com>
References: <CAMbWs48biJp-vof82PNP_LzzFkURh0W+RKt4phoML-MyYavgdg@mail.gmail.com>
	<[email protected]>
	<CAMbWs48vC37+j0V1SnHGRTP55AAaFyAYEbYGzh7UBKoWfh=E0w@mail.gmail.com>
	<CAMbWs4-_fDPOiYJWj330pJS++kKbTw_EfO5-pC8nPKHUAScMWw@mail.gmail.com>

Richard Guo <[email protected]> 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






view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Remove no-op PlaceHolderVars
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox