Decimal64 and Decimal128 - Mailing list pgsql-hackers

From Feng Tian
Subject Decimal64 and Decimal128
Date
Msg-id CAFWGqnsuyOKdOwsNLVtDU1LLjS=66xmxxxS8Chnng_zSB5_uCg@mail.gmail.com
Whole thread Raw
Responses Re: Decimal64 and Decimal128  (Feng Tian <ftian@vitessedata.com>)
Re: Decimal64 and Decimal128  (Peter Geoghegan <pg@heroku.com>)
Re: Decimal64 and Decimal128  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-hackers
Hi,

Here is an extension for 64 and 128 bit decimal types using IEEE decimal floating point.  The original idea/implementation is from http://pgxn.org/dist/pgdecimal/1.0.0/   Original thread for dicussion is at 


I reimplemented 64/128 bits instead of 32/64 bits.  The code use decNumber library instead of _Decimal64/128 of GCC.   Also added more operators.

Compared to numeric type, decimal64 arithmetics is about 2x faster, decimal128 is about 1.5x faster.  However, the cast between decimal and float4/8 is implemented rather naively and slow.   As always, it depends on workload, decimal may take more, or less space, may be slower if cast is frequently performed.

Agains, thanks to the original author okbob (Pavel).   Enjoy.

Thanks,
Feng

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Rename withCheckOptions to insertedCheckClauses
Next
From: Feng Tian
Date:
Subject: Re: Decimal64 and Decimal128