Re: wip: functions median and percentile - Mailing list pgsql-hackers

From Tom Lane
Subject Re: wip: functions median and percentile
Date
Msg-id 22725.1286806133@sss.pgh.pa.us
Whole thread Raw
In response to Re: wip: functions median and percentile  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: wip: functions median and percentile
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Oct 10, 2010 at 5:16 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> It was pointed out upthread that while median isn't presently
>> in the standard, Oracle defines it in terms of percentile_cont(0.5)
>> which *is* in the standard. �What I read in SQL:2008 is that
>> percentile_cont is defined for all numeric types (returning
>> approximate numeric with implementation-defined precision),
>> and for interval (returning interval), and not for any other
>> input type. �So it appears to me that what we ought to support
>> is
>> � � � �median(float8) returns float8
>> � � � �median(interval) returns interval
>> and nothing else --- we can rely on implicit casting to convert
>> any other numeric input type to float8.

> Isn't there a possibility of a precision loss if numeric gets cast to
> float8?

So?  The standard says "implementation-defined precision".  We can
define it as giving results that are good to float8.  I find it hard to
imagine an application for median() where that's not good enough;
and what's more, the difference in comparison speed between float8 and
numeric would render median() on numeric pretty useless anyway.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: wip: functions median and percentile
Next
From: Tom Lane
Date:
Subject: Re: On the usefulness of hint bits