Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the harmean function for speed #12

Open
Nate-Wessel opened this issue Dec 5, 2023 · 0 comments
Open

Optimize the harmean function for speed #12

Nate-Wessel opened this issue Dec 5, 2023 · 0 comments
Assignees

Comments

@Nate-Wessel
Copy link

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

@Nate-Wessel Nate-Wessel self-assigned this Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant