Postgres Performance: To avg or To sum/count
citusdata.com
citusdata.com
> In summary, partitioning SQL queries into smaller commutative ones helps you get linear performance improvements as you scale out. And in some cases, they may help you get even more. :)
The time difference between avg() and sum()/count() is merely a performance tuning opportunity in this specific case in specifically Postgres. MySQL, Oracle, etc. are going to have completely different implementations of these functions, and hypothetically could be the exact OPPOSITE performance. However this is not to degrade the insight presented in the actual body of this blog post.
"the numeric average function uses an array of two numerics to keep track of the current sum and count."