Re: double and numeric conversion - Mailing list pgsql-hackers

From Tom Lane
Subject Re: double and numeric conversion
Date
Msg-id 24694.1267479349@sss.pgh.pa.us
Whole thread Raw
In response to double and numeric conversion  (Theo Schlossnagle <jesus@omniti.com>)
Responses Re: double and numeric conversion
List pgsql-hackers
Theo Schlossnagle <jesus@omniti.com> writes:
> I'm writing some extension and I have a hot code path that has a lot of double (C type) data and needs to output
NUMERICtuple data.  The current methods I can find in the code to convert sprintf the double to a buffer and then
invokethe numeric_in function on them.  I've profile my stuff and I'm spending (wasting) all my time in that
conversion. Is there a more efficient method of converting a double into a postgres numeric value?
 

If you're worried about micro-optimization, why are you using NUMERIC at
all?  It's no speed demon.

Although you might be able to shave some cycles with a dedicated code
path for this conversion, binary to decimal is fundamentally not cheap.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: function side effects
Next
From: Boszormenyi Zoltan
Date:
Subject: Re: function side effects