I've noticed that the public.harmean function can be around 3x slower than doing e.g.
COUNT(*) / SUM( 1 / var )
See also, on literally this exact same topic:
https://dba.stackexchange.com/questions/243804/user-defined-harmonic-mean-function-performs-worse-than-query-in-postgresql-9-6
Is it possible that the numeric type is to blame?
However, calculations on numeric values are very slow compared to the integer types, or to the floating-point types described in the next section.
from https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL
I've noticed that the
public.harmeanfunction can be around 3x slower than doing e.g.See also, on literally this exact same topic:
https://dba.stackexchange.com/questions/243804/user-defined-harmonic-mean-function-performs-worse-than-query-in-postgresql-9-6
Is it possible that the numeric type is to blame?
from https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL