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? ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| ||||
| 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 |