AggregateFunctiondoes. This optimization can be applied to functions for which the following property holds: the result of applying a function
fto a row set
S1 UNION ALL S2can be obtained by applying
fto parts of the row set separately, and then again applying
fto the results:
f(S1 UNION ALL S2) = f(f(S1) UNION ALL f(S2)). This property guarantees that partial aggregation results are enough to compute the combined one, so we don’t have to store and process any extra data.
The common way to produce an aggregate function value is by calling the aggregate function with the -SimpleState suffix.
The following aggregate functions are supported:
Values of the
SimpleAggregateFunction(func, Type) look and stored the same way as
Type, so you do not need to apply functions with
SimpleAggregateFunction has better performance than
AggregateFunction with same aggregation function.
CREATE TABLE simple (id UInt64, val SimpleAggregateFunction(sum, Double)) ENGINE=AggregatingMergeTree ORDER BY id;
Rating: 1.8 - 22 votesWas this content helpful?