• Tom Lane's avatar
    Rewrite the rbtree routines so that an RBNode is the first field of the · 0454f131
    Tom Lane authored
    struct representing a tree entry, rather than being a separately allocated
    piece of storage.  This API is at least as clean as the old one (if not
    more so --- there were some bizarre choices in there) and it permits a
    very substantial memory savings, on the order of 2X in ginbulk.c's usage.
    
    Also, fix minor memory leaks in code called by ginEntryInsert, in
    particular in ginInsertValue and entryFillRoot, as well as ginEntryInsert
    itself.  These leaks resulted in the GIN index build context continuing
    to bloat even after we'd filled it to maintenance_work_mem and started
    to dump data out to the index.
    
    In combination these fixes restore the GIN index build code to honoring
    the maintenance_work_mem limit about as well as it did in 8.4.  Speed
    seems on par with 8.4 too, maybe even a bit faster, for a non-pathological
    case in which HEAD was formerly slower.
    
    Back-patch to 9.0 so we don't have a performance regression from 8.4.
    0454f131
ginfast.c 21.9 KB