Skip to content

pg_aggregate

The pg_aggregate table stores information about aggregate functions. An aggregate function is a function that operates on a set of values (typically one column from each row that matches a query condition) and returns a single value computed from all these values. Typical aggregate functions are sum, count, and max. Each entry in pg_aggregate is an extension of an entry in pg_proc. The pg_proc entry carries the aggregate's name, input and output data types, and other information that is similar to ordinary functions.

columntypereferencesdescription
aggfnoidregprocpg_proc.oidOID of the aggregate function
aggkindcharAggregate kind: n for normal aggregates, o for ordered-set aggregates, or h for hypothetical-set aggregates
aggnumdirectargssmallintNumber of direct (non-aggregated) arguments of an ordered-set or hypothetical-set aggregate, counting a variadic array as one argument. If equal to pronargs, the aggregate must be variadic and the variadic array describes the aggregated arguments as well as the final direct arguments. Always zero for normal aggregates.
aggtransfnregprocpg_proc.oidTransition function OID
aggfinalfnregprocpg_proc.oidFinal function OID (zero if none)
aggcombinefnregprocpg_proc.oidCombine function OID (zero if none)
aggserialfnregprocpg_proc.oidOID of the serialization function to convert transtype to bytea (zero if none)
aggdeserialfnregprocpg_proc.oidOID of the deserialization function to convert bytea to transtype (zero if none)
aggmtransfnregprocpg_proc.oidForward transition function OID for moving-aggregate mode (zero if none)
aggminvtransfnregprocpg_proc.oidInverse transition function OID for moving-aggregate mode (zero if none)
aggmfinalfnregprocpg_proc.oidFinal function OID for moving-aggregate mode (zero if none)
aggfinalextraboolTrue to pass extra dummy arguments to aggfinalfn
aggmfinalextraboolTrue to pass extra dummy arguments to aggmfinalfn
aggfinalmodifycharIndicates whether aggfinalfn modifies the transition state
aggmfinalmodifycharIndicates whether aggmfinalfn modifies the transition state
aggsortopoidpg_operator.oidAssociated sort operator OID (zero if none)
aggtranstypeoidpg_type.oidData type of the aggregate function's internal transition (state) data
aggtransspaceintegerApproximate average size (in bytes) of the transition state data, or zero to use a default estimate
aggmtranstypeoidpg_type.oidData type of the aggregate function's internal transition (state) data for moving-aggregate mode (zero if none)
aggmtransspaceintegerApproximate average size (in bytes) of the transition state data for moving-aggregate mode, or zero to use a default estimate
agginitvaltextThe initial value of the transition state. This is a text field containing the initial value in its external string representation. If this field is NULL, the transition state value starts out NULL.
aggminitvaltextThe initial value of the transition state for moving- aggregate mode. This is a text field containing the initial value in its external string representation. If this field is NULL, the transition state value starts out NULL.
aggrepsafeexecboolTrue to specify that the aggregate can be safely executed on replicated slices. An order-agnostic aggregate would be considered safe in this context.

Parent topic: System Catalogs Definitions