Summary
The catalog pg_aggregate 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.
(Description quoted from the official PostgreSQL documentation.)
Columns
The pg_aggregate system catalog exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):
aggfnoidregprocreferencespg_proc.oid
pg_proc OID of the aggregate functionaggkindchar
Aggregate kind: n for “normal” aggregates, o for “ordered-set” aggregates, or h for “hypothetical-set” aggregatesaggnumdirectargsint2
Number 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.aggtransfnregprocreferencespg_proc.oid
Transition functionaggfinalfnregprocreferencespg_proc.oid
Final function (zero if none)aggcombinefnregprocreferencespg_proc.oid
Combine function (zero if none)aggserialfnregprocreferencespg_proc.oid
Serialization function (zero if none)aggdeserialfnregprocreferencespg_proc.oid
Deserialization function (zero if none)aggmtransfnregprocreferencespg_proc.oid
Forward transition function for moving-aggregate mode (zero if none)aggminvtransfnregprocreferencespg_proc.oid
Inverse transition function for moving-aggregate mode (zero if none)aggmfinalfnregprocreferencespg_proc.oid
Final function for moving-aggregate mode (zero if none)aggfinalextrabool
True to pass extra dummy arguments to aggfinalfnaggmfinalextrabool
True to pass extra dummy arguments to aggmfinalfnaggfinalmodifychar
Whether aggfinalfn modifies the transition state value: r if it is read-only, s if the aggtransfn cannot be applied after the aggfinalfn, or w if it writes on the valueaggmfinalmodifychar
Like aggfinalmodify, but for the aggmfinalfnaggsortopoidreferencespg_operator.oid
Associated sort operator (zero if none)aggtranstypeoidreferencespg_type.oid
Data type of the aggregate function’s internal transition (state) dataaggtransspaceint4
Approximate average size (in bytes) of the transition state data. A positive value provides an estimate; zero means to use a default estimate. A negative value indicates the state data can grow unboundedly in size, such as when the aggregate accumulates input rows (e.g., array_agg, string_agg).aggmtranstypeoidreferencespg_type.oid
Data type of the aggregate function’s internal transition (state) data for moving-aggregate mode (zero if none)aggmtransspaceint4
Approximate average size (in bytes) of the transition state data for moving-aggregate mode, or zero to use a default estimateagginitvaltext
The 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.aggminitvaltext
The 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.
Related catalogs
This object references the following other system catalogs:
aggfnoid→pg_procaggsortop→pg_operatoraggtranstype→pg_type
Version applicability
Present in PostgreSQL 17, 18, 19 (verified against each release’s documentation). This is a long-standing system object that also exists in earlier PostgreSQL releases.
Related & references
Reference: PostgreSQL documentation — pg_aggregate.