Skip to content

Commit d17b6df

Browse files
committed
Fix knn-GiST queue comparison function to return heap tuples first.
The part of the comparison function that was supposed to keep heap tuples ahead of index items was backwards. It would not lead to incorrect results, but it is more efficient to return heap tuples first, before scanning more index pages, when both have the same distance. Alexander Korotkov
1 parent 2e105de commit d17b6df

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/access/gist/gistscan.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ pairingheap_GISTSearchItem_cmp(const pairingheap_node *a, const pairingheap_node
4141

4242
/* Heap items go before inner pages, to ensure a depth-first search */
4343
if (GISTSearchItemIsHeap(*sa) && !GISTSearchItemIsHeap(*sb))
44-
return -1;
45-
if (!GISTSearchItemIsHeap(*sa) && GISTSearchItemIsHeap(*sb))
4644
return 1;
45+
if (!GISTSearchItemIsHeap(*sa) && GISTSearchItemIsHeap(*sb))
46+
return -1;
4747

4848
return 0;
4949
}

0 commit comments

Comments
 (0)