Skip to content

Optimize the harmean function for speed #12

@Nate-Wessel

Description

@Nate-Wessel

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions