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

Re: wip: functions median and percentile

From: David Fetter <david(at)fetter(dot)org>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>,Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>,PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: wip: functions median and percentile
Date: 2010-08-19 17:03:20
Message-ID: 20100819170320.GA17368@fetter.org (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-rrreviewers
On Thu, Aug 19, 2010 at 12:49:45PM -0400, Robert Haas wrote:
> On Thu, Aug 19, 2010 at 11:33 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Greg Stark <gsstark(at)mit(dot)edu> writes:
> >> On Thu, Aug 19, 2010 at 11:59 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> >>> 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.
> >
> >> So if the entire result set fits in memory it would be nice to use the
> >> O(n) Quickselect algorithm -- which would only be a small change to
> >> the existing Quicksort code -- instead of sorting the entire set.
> >
> > That seems like rather a lot of added infrastructure for functions whose
> > popularity is at best unknown.  I think we should KISS for the first
> > implementation.
> 
> +1.  I think the functions are useful, but the perfect is the enemy of the good.

Percentile is already there as NTILE, a windowing function.  Median
may be useful, but we pretty much can't just call it "median."
Instead, we need to call it something like "left_median" or
"arithmetic_median."

Cheers,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david(dot)fetter(at)gmail(dot)com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2010-08-19 17:04:09
Subject: Re: CommitFest 2009-07: Yay, Kevin! Thanks, reviewers!
Previous:From: Tom LaneDate: 2010-08-19 16:57:26
Subject: Re: CommitFest 2009-07: Yay, Kevin! Thanks, reviewers!

pgsql-rrreviewers by date

Next:From: Kevin GrittnerDate: 2010-08-19 17:12:12
Subject: Re: wip: functions median and percentile
Previous:From: Robert HaasDate: 2010-08-19 16:49:45
Subject: Re: wip: functions median and percentile

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