[PATCH] Allow SJE to recognize GiST-backed temporal primary keys

Started by SATYANARAYANA NARLAPURAM7 months ago2 messageshackers

Thread notes

1 note#performance#moderate#enhancement
hackorum-bot#performance#moderate#enhancement
hackorum-bot
2 days ago

@global #performance #moderate #enhancement

#performance#moderate#enhancement
Jump to latest
#1SATYANARAYANA NARLAPURAM
satyanarlapuram@gmail.com

Hi Hackers,

relation_has_unique_index_for() checks whether join clause equality
operators belong to the index's opfamily via mergeopfamilies. Since
mergeopfamilies only lists btree opfamilies, this check always fails
for GiST-backed unique indexes such as those created by PRIMARY KEY
with WITHOUT OVERLAPS, preventing self-join elimination.

Fix by falling back to op_in_opfamily() when the mergeopfamilies check
fails. The clause is already known to be a mergejoinable equality, so
confirming the operator is registered in the index's opfamily is
sufficient to prove that the index's uniqueness guarantee applies.

Attached a patch to fix this and added corresponding tests.

Thanks,
Satya

Attachments:

t139412_1
0001-Allow-SJE-to-recognize-GiST-backed-temporal-primary-.patchapplication/octet-stream; name=0001-Allow-SJE-to-recognize-GiST-backed-temporal-primary-.patchDownload+61-2
#2David Rowley
dgrowleyml@gmail.com
In reply to: SATYANARAYANA NARLAPURAM (#1)
Re: [PATCH] Allow SJE to recognize GiST-backed temporal primary keys

On Wed, 22 Apr 2026 at 07:18, SATYANARAYANA NARLAPURAM
<satyanarlapuram@gmail.com> wrote:

relation_has_unique_index_for() checks whether join clause equality
operators belong to the index's opfamily via mergeopfamilies. Since
mergeopfamilies only lists btree opfamilies, this check always fails
for GiST-backed unique indexes such as those created by PRIMARY KEY
with WITHOUT OVERLAPS, preventing self-join elimination.

Please add to the 20-1 CF [1]https://commitfest.postgresql.org/59/.

David

[1]: https://commitfest.postgresql.org/59/