Re: New version of money type

From: "Luke Lonergan" <llonergan(at)greenplum(dot)com>
To: "Luke Lonergan" <llonergan(at)greenplum(dot)com>, "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>, "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: New version of money type
Date: 2006-09-28 16:40:04
Message-ID: C14148F4.2DFD%llonergan@greenplum.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

D'Arcy,

On 9/28/06 9:00 AM, "Luke Lonergan" <llonergan(at)greenplum(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2006-09-28 16:44:24 Re: New version of money type
Previous Message Jim C. Nasby 2006-09-28 16:22:23 Re: Another idea for dealing with cmin/cmax