Re: NUMERIC private methods?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: David Fetter <david(at)fetter(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NUMERIC private methods?
Date: 2014-12-16 15:16:19
Message-ID: 1515.1418742979@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnakangas(at)vmware(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Claudio Freire 2014-12-16 15:28:57 Re: On partitioning
Previous Message Robert Haas 2014-12-16 15:15:12 Re: On partitioning