Opened 9 years ago

Closed 9 years ago

Last modified 5 years ago

#10924 closed (wontfix)

Should use variance() and stddev() rather than var_samp() and stddev_samp() on Postgresql < 8.2

Reported by: Richard Davies <richard.davies@…> Owned by:
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: richard.davies@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


As per , the aggregation functions var_pop(), var_samp(), stddev_pop(), and stddev_samp() were first introduced in Postgresql 8.2.

However, var_samp() and stddev_samp() were merely renamings of the pre-existing aggregates variance() and stddev(), so we could extend support to earlier versions of Postgresql by using those older function names where appropriate.

Change History (2)

comment:1 Changed 9 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

This works for Postgres, but unfortunately it poses problems cross-platform. MySQL uses StdDev and Variance as aliases for the population statistics, not the sample statistics. I believe the unofficial SQlite extension that supports stddev and variance does the same.

We could make the determination of the backend function a very complex affair in order to support every possible database, but in the interests of keeping implementations simple, I'm going to mark this wontfix. For those users using Postgres pre 8.2, defining a custom aggregate function isn't that difficult - in this case, it's just a matter of subclassing the Django provided aggregates and overriding the function name.

comment:2 Changed 5 years ago by Anssi Kääriäinen

Component: ORM aggregationDatabase layer (models, ORM)
Note: See TracTickets for help on using tickets.
Back to Top