Re: Decimal64 and Decimal128

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Feng Tian <ftian(at)vitessedata(dot)com>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Decimal64 and Decimal128
Date: 2015-09-24 21:57:33
Message-ID: CAEepm=2+2N62dD6PK37PdEe1WuzdjuX+yzLS1KzfN=NQM_vq4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 25, 2015 at 9:23 AM, Feng Tian <ftian(at)vitessedata(dot)com> wrote:
>
>
> On Thu, Sep 24, 2015 at 2:17 PM, Feng Tian <ftian(at)vitessedata(dot)com> wrote:
>>
>>
>>
>> On Thu, Sep 24, 2015 at 1:55 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
>>>
>>> On Thu, Sep 24, 2015 at 1:53 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> > Please include the actual patch as an attachment. We do not consider
>>> > mere
>>> > URLs to be acceptable patch submission format, because that provides no
>>> > permanent record in our archives of what was submitted.
>>>
>>> I was under the impression that this was not intended as a patch
>>> submission.
>>>
>>>
>>> --
>>> Peter Geoghegan
>>
>>
>> If there is enough interest, would be great for it to go into the official
>> contrib dir.
>> Thanks,
>>
>>
> Second thought, the extension depends on decNumber, which is either GPL, or
> ICU license. Maybe this is trouble.

This is a very cool feature. I would be great to get a useful class
of decimal numbers into a pass-by-value fixed sized standardised data
type.

The Intel BID library seems to have a more permissive license at first
glance. I have heard that the Intel library is faster than the IBM
library at a variety of arithmetic and conversions (YMMV; I saw an
unpublished benchmark result that I can't share) on commodity hardware
at least, and it would be interesting to test that. I wonder if BID
(a single integer significand field) is inherently better for software
implementations than DPD (the significand as an array of 10 bit wide
base-1000 digits called "declets", not entirely unlike our numeric's
encoding). Those using POWER hardware might want the option to use
DPD though, because they have hardware support for that.

Perhaps ideally there could be a build option to use any of the following:

1. The IBM decNum library
2. The IBM DFPAL library[1] (this maps to IBM hardware if available,
or decNum otherwise)
3. The Intel library
4. The future built-in C language support[2] (which could use either
binary format!), currently only a proposal but already implemented by
IBM XL C and GCC (using the libraries above)

I have a suspicion that if only one of those has to be chosen, the
Intel library would be best for the majority of users based on license
+ performances.

[1] http://speleotrove.com/decimal/dfpal/dfpalugaio.html
[2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1312.pdf,
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1781.pdf

--
Thomas Munro
http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-09-24 22:01:18 Re: [PROPOSAL] VACUUM Progress Checker.
Previous Message David Rowley 2015-09-24 21:50:56 Re: Decimal64 and Decimal128