Fix knn-GiST queue comparison function to return heap tuples first.
authorHeikki Linnakangas <[email protected]>
Tue, 17 Feb 2015 20:33:38 +0000 (22:33 +0200)
committerHeikki Linnakangas <[email protected]>
Tue, 17 Feb 2015 20:33:38 +0000 (22:33 +0200)
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

src/backend/access/gist/gistscan.c

index cc8d818e11df581946f31de3a7a51a639979ef40..991858ff43f837fd1a6d53d16321c33cd0cedae8 100644 (file)
@@ -41,9 +41,9 @@ pairingheap_GISTSearchItem_cmp(const pairingheap_node *a, const pairingheap_node
 
    /* Heap items go before inner pages, to ensure a depth-first search */
    if (GISTSearchItemIsHeap(*sa) && !GISTSearchItemIsHeap(*sb))
-       return -1;
-   if (!GISTSearchItemIsHeap(*sa) && GISTSearchItemIsHeap(*sb))
        return 1;
+   if (!GISTSearchItemIsHeap(*sa) && GISTSearchItemIsHeap(*sb))
+       return -1;
 
    return 0;
 }