• Tom Lane's avatar
    Improve performance of numeric sum(), avg(), stddev(), variance(), etc. · 69c8fbac
    Tom Lane authored
    This patch improves performance of most built-in aggregates that formerly
    used a NUMERIC or NUMERIC array as their transition type; this includes
    not only aggregates on numeric inputs, but some aggregates on integer
    inputs where overflow of an int8 value is a possibility.  The code now
    uses a special-purpose data structure to avoid array construction and
    deconstruction overhead, as well as packing and unpacking overhead for
    numeric values.
    
    These aggregates' transition type is now declared as INTERNAL, since
    it doesn't correspond to any SQL data type.  To keep the planner from
    thinking that that means a lot of storage will be used, we make use
    of the just-added pg_aggregate.aggtransspace feature.  The space estimate
    is set to 128 bytes, which is at least in the right ballpark.
    
    Hadi Moshayedi, reviewed by Pavel Stehule and Tomas Vondra
    69c8fbac
catversion.h 2.53 KB