• Andres Freund's avatar
    Don't require return slots for nodes without projection. · 1ef6bd29
    Andres Freund authored
    In a lot of nodes the return slot is not required. That can either be
    because the node doesn't do any projection (say an Append node), or
    because the node does perform projections but the projection is
    optimized away because the projection would yield an identical row.
    
    Slots aren't that small, especially for wide rows, so it's worthwhile
    to avoid creating them.  It's not possible to just skip creating the
    slot - it's currently used to determine the tuple descriptor returned
    by ExecGetResultType().  So separate the determination of the result
    type from the slot creation.  The work previously done internally
    ExecInitResultTupleSlotTL() can now also be done separately with
    ExecInitResultTypeTL() and ExecInitResultSlot().  That way nodes that
    aren't guaranteed to need a result slot, can use
    ExecInitResultTypeTL() to determine the result type of the node, and
    ExecAssignScanProjectionInfo() (via
    ExecConditionalAssignProjectionInfo()) determines that a result slot
    is needed, it is created with ExecInitResultSlot().
    
    Besides the advantage of avoiding to create slots that then are
    unused, this is necessary preparation for later patches around tuple
    table slot abstraction. In particular separating the return descriptor
    and slot is a prerequisite to allow JITing of tuple deforming with
    knowledge of the underlying tuple format, and to avoid unnecessarily
    creating JITed tuple deforming for virtual slots.
    
    This commit removes a redundant argument from
    ExecInitResultTupleSlotTL(). While this commit touches a lot of the
    relevant lines anyway, it'd normally still not worthwhile to cause
    breakage, except that aforementioned later commits will touch *all*
    ExecInitResultTupleSlotTL() callers anyway (but fits worse
    thematically).
    
    Author: Andres Freund
    Discussion: https://postgr.es/m/20181105210039.hh4vvi4vwoq5ba2q@alap3.anarazel.de
    1ef6bd29
nodeSort.c 11 KB