Re: Remove extra Sort node above a btree-compatible Index Scan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Remove extra Sort node above a btree-compatible Index Scan
Date: 2025-02-28 05:43:17
Message-ID: 2681345.1740721397@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com> writes:
> I’ve attached a patch that removes this unnecessary Sort node for
> B-tree-compatible indexes.

This does not look right at all. You can't just ignore the opfamily
etc. while deciding whether two pathkeys represent the same sort
ordering, as you did in create_mergejoin_plan(). I don't like
pathkeys_have_same_sortop() either. The pathkey data structures
were designed to let pointer comparison be sufficient for deciding
whether pathkeys are equivalent: see the "canonical pathkey" stuff
in pathkeys.c. I think that this patch may be band-aiding over some
breakage of that concept, but you've not provided enough context to
figure out what the underlying problem is.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-02-28 05:54:44 Re: Log connection establishment timings
Previous Message R, Rakshit 2025-02-28 05:43:16 RE: SIMD optimization for list_sort