Re: Money casting too liberal?

From: Shaun Thomas <sthomas(at)optionshouse(dot)com>
To: Gavan Schneider <pg-gts(at)snkmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Money casting too liberal?
Date: 2013-03-28 13:52:16
Message-ID: 51544B10.4000900@optionshouse.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/28/2013 07:43 AM, Gavan Schneider wrote:

> Personally I have ignored the money type in favour of numeric. Money
> seemed to do too much behind the scenes for my taste, but, that's me
> being lazy as well, I haven't spend much time trying to understand its
> features.

You're not the only one. In the financial industry, we can't even use
the money type for a few reasons:

1. It's very common for values to have fractional amounts in the
selected currency. Just look at gas stations... they could never use the
Money type in the US thanks to the "3.989" pricing they commonly employ.

2. You can't use the Money type for non-local currencies. Our database
may store transactions in several base currencies. Sure, the smart thing
would be to save the exchange rate at the time of the transaction and
store the local value and the rate, but then you'd have to reverse that
calculation to get the original value, and without decimals, that
conversion would be wrong in most cases.

So we use numeric. It's the only thing with the guaranteed precision we
need, and prettying up the display is easy to do client-side. We're
extremely happy to see the recent improvements in numeric performance
that seem to be coming in 9.3. :)

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604
312-676-8870
sthomas(at)optionshouse(dot)com

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-03-28 14:36:28 Re: Money casting too liberal?
Previous Message D'Arcy J.M. Cain 2013-03-28 13:28:19 Re: Money casting too liberal?