79772225

Date: 2025-09-23 05:04:36
Score: 0.5
Natty:
Report link

The SimpleAggregateFunction stores the intermediate state of an aggregate function(eg: max, sum, count), but not its full state as the AggregateFunction (eg: avg, unique). AggregateFunction stores the entire values required to calculate the result.

Use SimpleAggregateFunction if f(R1 UNION ALL R2) = f(f(R1) UNION ALL f(R2)).

eg: sum(A1,A2,A3,B1,B2) = sum(sum(A1,A2,A3) , sum(B1,B2))

Use AggregateFunction otherwise

eg: avg(A1,A2,A3,B1,B2) != avg(avg(A1,A2,A3) , avg(B1,B2))

Note that SimpleAggregateFunction is faster, hence prefer the same over AggregateFunction if the requirement doesn't require full states for the result calculation.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: user1991251