Re: Redundant Result node

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Redundant Result node
Date: 2024-08-27 03:29:52
Message-ID: CAMbWs4_JtkpPsF8+Xh=StbzTd3KqGeUgmuDiucyJhfG2e3=3EA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 26, 2024 at 8:58 PM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
> On 23.08.24 10:27, Richard Guo wrote:
> > Fair point. After looking at the code for a while, I believe it is
> > sufficient to compare PathTarget.exprs after we've checked that the
> > two targets have different pointers.
>
> - if (sorted_path->pathtarget != target)
> + if (sorted_path->pathtarget != target &&
> + !equal(sorted_path->pathtarget->exprs, target->exprs))
> sorted_path = apply_projection_to_path(root, ordered_rel,
>
> equal() already checks whether both pointers are equal, so I think this
> could be simplified to just
>
> if (!equal(sorted_path->pathtarget->exprs, target->exprs))

Indeed. If the target pointers are equal, the PathTarget.exprs
pointers must be equal too.

Attached is the updated patch with this change.

Thanks
Richard

Attachment Content-Type Size
v2-0001-Avoid-unnecessary-post-sort-projection.patch application/octet-stream 4.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-08-27 03:35:00 Re: Statistics Import and Export
Previous Message Amit Kapila 2024-08-27 03:20:57 Re: Doc: fix the note related to the GUC "synchronized_standby_slots"