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

Re: double and numeric conversion

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Theo Schlossnagle <jesus(at)omniti(dot)com>
Cc: PostgreSQL-development Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: double and numeric conversion
Date: 2010-03-01 21:35:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Theo Schlossnagle <jesus(at)omniti(dot)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 NUMERIC tuple data.  The current methods I can find in the code to convert sprintf the double to a buffer and then invoke the 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

In response to


pgsql-hackers by date

Next:From: Boszormenyi ZoltanDate: 2010-03-01 21:40:40
Subject: Re: function side effects
Previous:From: Tom LaneDate: 2010-03-01 21:29:56
Subject: Re: function side effects

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