• Andres Freund's avatar
    Don't reuse slots between root and partition in ON CONFLICT ... UPDATE. · 277cb789
    Andres Freund authored
    Until now the the slot to store the conflicting tuple, and the result
    of the ON CONFLICT SET, where reused between partitions. That
    necessitated changing slots descriptor when switching partitions.
    
    Besides the overhead of switching descriptors on a slot (which
    requires memory allocations and prevents JITing), that's importantly
    also problematic for tableam. There individual partitions might belong
    to different tableams, needing different kinds of slots.
    
    In passing also fix ExecOnConflictUpdate to clear the existing slot at
    exit. Otherwise that slot could continue to hold a pin till the query
    ends, which could be far too long if the input data set is large, and
    there's no further conflicts. While previously also problematic, it's
    now more important as there will be more such slots when partitioned.
    
    Author: Andres Freund
    Reviewed-By: Robert Haas, David Rowley
    Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
    277cb789
nodeModifyTable.c 80.9 KB