Re: An inefficient query caused by unnecessary PlaceHolderVar

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: James Coleman <jtc331@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2023-07-18T07:17:15Z
Lists: pgsql-hackers

Attachments

On Fri, Jun 2, 2023 at 1:33 AM James Coleman <jtc331@gmail.com> wrote:

> On Wed, May 31, 2023 at 10:30 PM Richard Guo <guofenglinux@gmail.com>
> wrote:
> > Thanks for the review!
>
> Sure thing!


I've updated the patch according to the reviews as attached.  But I did
not add ORDER BY clause in the test, as we don't need it for correctness
for this test query and the surrounding queries in join.sql don't have
ORDER BY either.

Thanks
Richard

Commits

  1. Avoid unnecessary wrapping for Vars and PHVs

  2. Avoid mislabeling of lateral references, redux.

  3. Avoid inserting PlaceHolderVars in cases where pre-v16 PG did not.