Re: Numeric patch to add special-case representations for < 8 bytes

From: Patric Bechtel <bechtel(at)ipcon(dot)de>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Numeric patch to add special-case representations for < 8 bytes
Date: 2007-03-01 01:37:28
Message-ID: 45E62E58.6060901@ipcon.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Gregory Stark schrieb am 27.02.2007 01:39:
> I've uploaded a quick hack to store numerics in < 8 bytes when possible.
>
> http://community.enterprisedb.com/numeric-hack-1.patch
>
> This is a bit of a kludge since it doesn't actually provide any interface for
> external clients of the numeric module to parse the resulting data. Ie, the
> macros in numeric.h will return garbage.
>
> But I'm not entirely convinced that matters. It's not like those macros were
> really useful to any other modules anyways since there was no way to extract
> the actual digits.
>
> The patch is also slightly unsatisfactory because as I discovered numbers like
> 1.1 are stored as two digits currently. But it does work and it does save a
> substantial amount of space for integers.
>
> postgres=# select n,pg_column_size(n) from n;
> n | pg_column_size
> ----------+----------------
> 1 | 2
> 11 | 2
> 101 | 2
> 1001 | 3
> 10001 | 9
> 100001 | 9
> 1.1 | 9
> 10.1 | 9
> 100.1 | 9
> 1000.1 | 9
> 10000.1 | 11
> 100000.1 | 11
>
> I had hoped to get the second batch to be 3-4 bytes. But even now note how
> much space is saved for integers <10000.
>
>
Very nice :-) I'm looking forward to something like that. We store huge
quantities of numerics in our DB's (I strongly discourage using ANSI754
floats anywhere).
Maybe you want to have a look here:
http://www2.hursley.ibm.com/decimal/DPDecimal.html

just my 0.02$... ;-)

Patric

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-03-01 02:06:15 Re: [HACKERS] Deadlock with pg_dump?
Previous Message Takayuki Tsunakawa 2007-03-01 00:45:53 Re: Dead Space Map version 2