• Heikki Linnakangas's avatar
    Add some randomness to the choice of which GiST page to insert to. · ba1cc650
    Heikki Linnakangas authored
    When descending the tree for an insert, and there are multiple equally good
    pages we could insert to, make the choice in random. Previously, we would
    always choose the tuple with lowest offset number. That meant that when two
    non-leaf pages overlap - in the extreme case they might have exactly the same
    key - all but the first such page went unused. That wasn't optimal for space
    usage; if you deleted some tuples from the non-first pages, the space would
    never be reused.
    
    With this patch, the other pages are sometimes chosen too, although there's
    still a heavy bias towards low-offset tuples, so that we don't lose cache
    locality when doing a lot of inserts with similar keys.
    
    Original idea by Alexander Korotkov, although this patch version was written
    by me and copy-edited by Tom Lane.
    ba1cc650
gistutil.c 20 KB