Unix Technical Forum

Re: New version of money type

This is a discussion on Re: New version of money type within the pgsql Hackers forums, part of the PostgreSQL category; --> Oic - so it's a floating point in an 8 byte int. That probably limits the speed benefits, no? ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 05:00 AM
Luke Lonergan
 
Posts: n/a
Default Re: New version of money type

Oic - so it's a floating point in an 8 byte int. That probably limits the speed benefits, no?

- Luke

Msg is shrt cuz m on ma treo

-----Original Message-----
From: D'Arcy J.M. Cain [mailto:darcy@druid.net]
Sent: Thursday, September 28, 2006 11:14 AM Eastern Standard Time
To: Luke Lonergan
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] New version of money type

On Thu, 28 Sep 2006 11:09:17 -0400
"Luke Lonergan" <LLonergan@greenplum.com> wrote:
> Though this may be the kiss of death, I favor a 64 bit float version of money. It's more terse than numeric and a


I assume you mean "...64 bit INT version..."

--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 05:00 AM
D'Arcy J.M. Cain
 
Posts: n/a
Default Re: New version of money type

On Thu, 28 Sep 2006 11:25:45 -0400
"Luke Lonergan" <LLonergan@greenplum.com> wrote:
> Oic - so it's a floating point in an 8 byte int. That probably limits the speed benefits, no?


No, it's an int type. Floating point has nothing to do with the money
type, either in the old 32 bit version or the proposed 64 bit version.
It does display in a DECIMAL format but just because there is a decimal
point in the output does not make it floating point. All internal
calculations are done as integer arithmetic.

--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 05:00 AM
Jim C. Nasby
 
Posts: n/a
Default Re: New version of money type

On Thu, Sep 28, 2006 at 11:32:37AM -0400, D'Arcy J.M. Cain wrote:
> On Thu, 28 Sep 2006 11:25:45 -0400
> "Luke Lonergan" <LLonergan@greenplum.com> wrote:
> > Oic - so it's a floating point in an 8 byte int. That probably limits the speed benefits, no?

>
> No, it's an int type. Floating point has nothing to do with the money
> type, either in the old 32 bit version or the proposed 64 bit version.
> It does display in a DECIMAL format but just because there is a decimal
> point in the output does not make it floating point. All internal
> calculations are done as integer arithmetic.


Floating point math and hard-earned money are two things that don't mix
well.
--
Jim Nasby jim@nasby.net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 05:00 AM
D'Arcy J.M. Cain
 
Posts: n/a
Default Re: New version of money type

On Thu, 28 Sep 2006 10:35:01 -0500
"Jim C. Nasby" <jim@nasby.net> wrote:
> Floating point math and hard-earned money are two things that don't mix
> well.


Using FP to track money is a good way to stop making any. :-)

--
D'Arcy J.M. Cain <darcy@druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 05:00 AM
Luke Lonergan
 
Posts: n/a
Default Re: New version of money type

D'Arcy,

On 9/28/06 8:43 AM, "D'Arcy J.M. Cain" <darcy@druid.net> wrote:

> On Thu, 28 Sep 2006 10:35:01 -0500
> "Jim C. Nasby" <jim@nasby.net> wrote:
>> Floating point math and hard-earned money are two things that don't mix
>> well.

>
> Using FP to track money is a good way to stop making any. :-)


Understood - a cent here and there in rounding can add up, as the earliest
hackers found out.

What I meant is the use of the "point" that "floats", is there an exponent
stored as part of the format? If so, then the integer arithmetic is not
standard integer operands, right?

Which routines implement the money arithmetic?

- Luke



---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-12-2008, 05:01 AM
Luke Lonergan
 
Posts: n/a
Default Re: New version of money type

D'Arcy,

On 9/28/06 9:00 AM, "Luke Lonergan" <llonergan@greenplum.com> wrote:

> Which routines implement the money arithmetic?


Ok - so now having read the old documentation and the routine "
backend/utils/adt/cash.c" and the type definition for Cash in "
backend/include/utils/adt/cash.h" I can see that it's:

- Fixed point at NNN.MM
- Stored as an INT32 (or your proposed INT64)
- Operations use native operands (=<>+*/)

The disappointing thing is that there is always a function call involved in
any arithmetic operation. An even larger benefit could probably be gained
by inlining the routines in cash.c, which is probably inhibited by the
"FUNCTIONCALLxxx" indirections in the executor for operators (different
topic).

So, the NUMERIC arithmetic must be really slow to get 10% improvements in
computational speed.

Based on all of this, I know I would use the 64 bit money type for things
like the TPC-H benchmark...

- Luke



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:43 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com