52.2. pg_aggregate
pg_aggregate
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.
Column Type Description |
|---|
aggfnoid pg_proc OID of the aggregate function |
aggkind Aggregate kind: |
aggnumdirectargs 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. |
aggtransfn Transition function |
aggfinalfn Final function (zero if none) |
aggcombinefn Combine function (zero if none) |
aggserialfn Serialization function (zero if none) |
aggdeserialfn Deserialization function (zero if none) |
aggmtransfn Forward transition function for moving-aggregate mode (zero if none) |
aggminvtransfn Inverse transition function for moving-aggregate mode (zero if none) |
aggmfinalfn Final function for moving-aggregate mode (zero if none) |
aggfinalextra True to pass extra dummy arguments to aggfinalfn |
aggmfinalextra True to pass extra dummy arguments to aggmfinalfn |
aggfinalmodify Whether aggfinalfn modifies the transition state value: |
aggmfinalmodify Like aggfinalmodify, but for the aggmfinalfn |
aggsortop Associated sort operator (zero if none) |
aggtranstype Data type of the aggregate function's internal transition (state) data |
aggtransspace Approximate average size (in bytes) of the transition state data, or zero to use a default estimate |
aggmtranstype Data type of the aggregate function's internal transition (state) data for moving-aggregate mode (zero if none) |
aggmtransspace Approximate average size (in bytes) of the transition state data for moving-aggregate mode, or zero to use a default estimate |
agginitval 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. |
aggminitval 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. |
: pg_aggregate Columns
New aggregate functions are registered with the CREATE AGGREGATE command. See User-Defined Aggregates for more information about writing aggregate functions and the meaning of the transition functions, etc.