Re: NUMERIC private methods? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: NUMERIC private methods?
Date
Msg-id 1515.1418742979@sss.pgh.pa.us
Whole thread Raw
In response to Re: NUMERIC private methods?  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: NUMERIC private methods?  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-hackers
Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> On 12/16/2014 08:34 AM, David Fetter wrote:
>> While noodling with some weighted statistics
>> <https://github.com/davidfetter/weighted_stats>, I noticed I was
>> having to jump through a lot of hoops because of all the private
>> methods in numeric.c, especially NumericVar.  Would there be some
>> major objection to exposing NumericVar as an opaque blob?

> Hmm. You'd want to make add_var, mul_var etc. non-static?

-1 for that.

> Looking at the weighed_stats code, this probably illustrates the hoops 
> you had to jump through:

>> /* sqrt((n/(n-1)) * ((s0*s2 - s1*s1)/(s0*s0)) */

If you're concerned about arithmetic performance, there is a very obvious
fix here: use double.  Is there some utterly compelling reason to use
numeric, despite the fact that it's certain to be orders of magnitude
slower?

(It would still be orders of magnitude slower, no matter how much we
were willing to destroy numeric.c's modularity boundary.)
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: On partitioning
Next
From: Claudio Freire
Date:
Subject: Re: On partitioning