[MDEV-4835] Add Median Function Created: 2013-08-01  Updated: 2017-12-18  Resolved: 2017-12-18

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Fix Version/s: 10.3.3

Type: Task Priority: Major
Reporter: Ben Hiles (Inactive) Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 3
Labels: None

Issue Links:
Duplicate
duplicates MDEV-12985 support percentile and median window ... Closed
PartOf
is part of MDEV-12987 complete window function support for ... Open
Relates
relates to MCOL-624 MariaDB 10.2 WF create MEDIAN, PERCEN... Closed

 Description   

When analyzing skewed data, median can be a better measure than mean.

Currently this can be implemented with a User Defined Function (e.g. http://www.mooreds.com/wordpress/archives/376), however this requires more overhead when upgrading and deploying database. This can also be handled with a query (e.g. http://stackoverflow.com/questions/1291152/simple-way-to-calculate-median-with-mysql), however that has a performance hit.

Would adding a new aggregate function be possible?



 Comments   
Comment by Sergei Golubchik [ 2013-08-08 ]

Yes, possible. But it's unlikely that we will have resources to do that anytime soon.

On the other hand, we'd be happy to apply a patch that implements this function, if someone would provide it to us.

https://kb.askmonty.org/en/contributing-code/

Comment by roberto spadim [ 2014-08-03 ]

There's many aleeady implemented udf functions, for example
https://github.com/megastep/mysql-udf?files=1

Comment by roberto spadim [ 2015-05-16 ]

there's more functions here, very interesting:
http://mysql-udf.sourceforge.net/

Comment by Ján Regeš [ 2015-09-25 ]

Hi,

we use UDF function "MEDIAN" from https://github.com/megastep/mysql-udf in our projects and it works well!

I think, that it could be a built-in part of MariaDB

Comment by Sergei Golubchik [ 2015-11-11 ]

When we'll be implementing it, it should probably be not MEDIAN(), but a more generic PERCENTILE().

Comment by Dipti Joshi (Inactive) [ 2017-06-06 ]

This is duplicate of MDEV-12985

Comment by Marc [ 2017-12-18 ]

@Sergei: why would you want to name it "PERCENTILE". Everybody know the mathematic function name median, so everybody will search it by that name.
But I'm hoping for that function to be integrated too.

Comment by Sergei Golubchik [ 2017-12-18 ]

Done. Both PERCENTILE and MEDIAN. See MDEV-12985

Comment by Ján Regeš [ 2017-12-18 ]

Thank you Sergei!

It's like a Christmas present ))

Generated at Thu Feb 08 06:59:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.