Code

Opened 5 years ago

Closed 5 years ago

Last modified 14 months 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:

Description

As per http://developer.postgresql.org/pgdocs/postgres/release-8-2.html , 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.

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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 14 months ago by akaariai

  • Component changed from ORM aggregation to Database layer (models, ORM)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.