Re: New version of money type

From: Jim Nasby <jimn(at)enterprisedb(dot)com>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Theo Schlossnagle <jesus(at)omniti(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: New version of money type
Date: 2006-09-18 02:00:56
Message-ID: ED1A19F7-084B-47EF-8989-568D9A6BFD3F@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sep 16, 2006, at 7:31 PM, Gregory Stark wrote:
>> Would that pose indexing issues? It would also mean that when
>> joining two
>> tables you'd have to handle some interesting type conversion
>> issues (at
>> times). We had someone accidentally create a largish table with
>> userid as
>> "numeric" and other tables are "bigint", it was disastrous for
>> performance
>> (joining). I'd imagine that if the above wasn't done cleverly, that
>> performance problem would be repeated.
>
> That used to be a problem but Tom solved it a little while back.
> Not a perfect
> solution in that it requires lots of cross-data-type operators as
> the number
> of data types grows but it works.
>
> In any case I think Jim was suggesting this be handled internally
> to the
> numeric data type which wouldn't cause this problem. However I'm
> not sure
> anything has to be done. A numeric is an array of 16 bit integers,
> so anything
> under 64k *is* stored just as an integer.

Yes, I definitely meant for this to be internal-only... end users
shouldn't notice any difference (except hopefully improved performance).

If all the math is done in 64k chunks then this might not be as big a
help. Numbers between 2^16 and 2^64 (or 2^32 on some platforms) would
probably be faster, but how much faster isn't clear. Perhaps the OP
could do some testing if someone came up with a quick and dirty
prototype patch.

> Well, just an integer plus a useless exponent. I think it would be
> a neat
> trick to normalize the exponent to the end of the last element of
> the mantissa
> rather than the first digit so that integers don't need an exponent.

How would that help? If I'm understanding correctly you're just
talking about storing how many places after the decimal instead of
how many in front of it?
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2006-09-18 02:07:48 Re: Mid cycle release?
Previous Message Andrew - Supernews 2006-09-18 02:00:46 Re: 8.2 beta blockers