• Peter Geoghegan's avatar
    Add "split after new tuple" nbtree optimization. · f21668f3
    Peter Geoghegan authored
    Add additional heuristics to the algorithm for locating an optimal split
    location.  New logic identifies localized monotonically increasing
    values in indexes with multiple columns.  When this insertion pattern is
    detected, page splits split just after the new item that provoked a page
    split (or apply leaf fillfactor in the style of a rightmost page split).
    This optimization is a variation of the long established leaf fillfactor
    optimization used during rightmost page splits.
    
    50/50 page splits are only appropriate with a pattern of truly random
    insertions, where the average space utilization ends up at 65% - 70%.
    Without this patch, affected cases have leaf pages that are no more than
    about 50% full on average.  Future insertions can never make use of the
    free space left behind.  With this patch, affected cases have leaf pages
    that are about 90% full on average (assuming a fillfactor of 90).
    
    Localized monotonically increasing insertion patterns are presumed to be
    fairly common in real-world applications.  There is a fair amount of
    anecdotal evidence for this.  Both pg_depend system catalog indexes
    (pg_depend_depender_index and pg_depend_reference_index) are at least
    20% smaller after the regression tests are run when the optimization is
    available.  Furthermore, many of the indexes created by a fair use
    implementation of TPC-C for Postgres are consistently about 40% smaller
    when the optimization is available.
    
    Note that even pg_upgrade'd v3 indexes make use of this optimization.
    
    Author: Peter Geoghegan
    Reviewed-By: Heikki Linnakangas
    Discussion: https://postgr.es/m/CAH2-WzkpKeZJrXvR_p7VSY1b-s85E3gHyTbZQzR0BkJ5LrWF_A@mail.gmail.com
    f21668f3
nbtsplitloc.c 36.2 KB