Re: Redundant Result node

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Redundant Result node
Date: 2024-08-22 11:15:00
Message-ID: CAApHDvo14gwvtSdhYzn=6CdUSaVpnMPwUct4Qx4j+fO+5TixoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 22 Aug 2024 at 19:34, Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> /* Add projection step if needed */
> if (sorted_path->pathtarget != target)
> sorted_path = apply_projection_to_path(root, ordered_rel,
> sorted_path, target);
>
> This does not seem right to me, as PathTargets are not canonical, so
> we cannot guarantee that two identical PathTargets will have the same
> pointer. Actually, for the query above, the two PathTargets are
> identical but have different pointers.
>
> I wonder if we need to invent a function to compare two PathTargets.
> Alternatively, in this case, would it suffice to simply compare
> PathTarget.exprs?

I think tlist.c would be a good home for such a function. If you go
with the function route, then it's easier to add optimisations such as
checking if the pointers are equal before going to the trouble of
checking if the exprs match.

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melih Mutlu 2024-08-22 11:26:11 Re: ANALYZE ONLY
Previous Message Jakub Wartak 2024-08-22 11:10:15 Re: Enable data checksums by default