Skip to content

max_frequency()

Get the maximum bound of the estimated frequency for a given value in a space-saving aggregate

Since 1.16.0

Get the maximum bound of the estimated frequency for a given value in a space-saving aggregate.

Find the maximum frequency of the value 3 in a column named value within the table value_test:

SELECT max_frequency(
(SELECT mcv_agg(20, value) FROM value_test),
3
);

The syntax is:

max_frequency (
agg SpaceSavingAggregate,
value AnyElement
) RETURNS DOUBLE PRECISION
NameTypeDefaultRequiredDescription
aggSpaceSavingAggregate-✔A space-saving aggregate created using either freq_agg or mcv_agg
valueAnyElement-✔The value to get the frequency of
ColumnTypeDescription
max_frequencyDOUBLE PRECISIONThe maximum bound for the value's estimated frequency. The result is 0 if the aggregate does not hold the value. For more information, see freq_agg.