On Mon, Aug 26, 2024 at 8:58 PM Peter Eisentraut <pe...@eisentraut.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: v2-0001-Avoid-unnecessary-post-sort-projection.patch
Description: Binary data

Reply via email to