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.
Table 51.2. pg_aggregate
Columns
Name  Type  References  Description 

aggfnoid 
regproc 

pg_proc OID of the aggregate function 
aggkind 
char 
Aggregate kind: n for “normal” aggregates, o for “orderedset” aggregates, or h for “hypotheticalset” aggregates 

aggnumdirectargs 
int2 
Number of direct (nonaggregated) arguments of an orderedset or hypotheticalset 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 
regproc 

Transition function 
aggfinalfn 
regproc 

Final function (zero if none) 
aggcombinefn 
regproc 

Combine function (zero if none) 
aggserialfn 
regproc 

Serialization function (zero if none) 
aggdeserialfn 
regproc 

Deserialization function (zero if none) 
aggmtransfn 
regproc 

Forward transition function for movingaggregate mode (zero if none) 
aggminvtransfn 
regproc 

Inverse transition function for movingaggregate mode (zero if none) 
aggmfinalfn 
regproc 

Final function for movingaggregate mode (zero if none) 
aggfinalextra 
bool 
True to pass extra dummy arguments to aggfinalfn 

aggmfinalextra 
bool 
True to pass extra dummy arguments to aggmfinalfn 

aggsortop 
oid 

Associated sort operator (zero if none) 
aggtranstype 
oid 

Data type of the aggregate function's internal transition (state) data 
aggtransspace 
int4 
Approximate average size (in bytes) of the transition state data, or zero to use a default estimate  
aggmtranstype 
oid 

Data type of the aggregate function's internal transition (state) data for movingaggregate mode (zero if none) 
aggmtransspace 
int4 
Approximate average size (in bytes) of the transition state data for movingaggregate mode, or zero to use a default estimate  
agginitval 
text 
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 
text 
The initial value of the transition state for movingaggregate 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. 
New aggregate functions are registered with the CREATE AGGREGATE command. See Section 37.10 for more information about writing aggregate functions and the meaning of the transition functions, etc.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.