Skip site navigation (1) Skip section navigation (2)

wip: functions median and percentile

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: David Fetter <david(at)fetter(dot)org>
Subject: wip: functions median and percentile
Date: 2010-08-19 10:59:33
Message-ID: AANLkTimRksUOgGsK7-gTXnvJJGL-1QvuqxidusZQwep6@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-rrreviewers
Hello

I am sending a prototype implementation of functions median and
percentile. This implementation is very simple and I moved it to
contrib for this moment - it is more easy maintainable. Later I'll
move it to core.

These functions are relative simple, there are not barrier for
implementation own specific mutations of this functions - so I propose
move to core only basic and well known form of these to core.

postgres=# select median(v) from generate_series(1,10) g(v);
 median
────────
    5.5
(1 row)

Time: 1.475 ms
postgres=# select percentile(v,50) from generate_series(1,10) g(v);
 percentile
────────────
          5
(1 row)

Time: 0.626 ms

This implementation is based on tuplesort and the speed is relative
well - the result from 1000000 rows is less 1 sec.

Regards

Pavel Stehule

Attachment: median.diff
Description: text/x-patch (7.7 KB)

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-08-19 13:00:23
Subject: Re: PL/pgsSQL EXECUTE USING INTO
Previous:From: Pavel StehuleDate: 2010-08-19 10:45:13
Subject: Re: proposal: tuplestore, tuplesort aggregate functions

pgsql-rrreviewers by date

Next:From: Greg StarkDate: 2010-08-19 14:50:23
Subject: Re: wip: functions median and percentile
Previous:From: Kevin GrittnerDate: 2010-08-18 21:45:47
Subject: CommitFest 2010-07 final report

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group