Re: Reducing the overhead of NUMERIC data

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Reducing the overhead of NUMERIC data
Date: 2005-11-06 08:45:58
Message-ID: 1131266758.8300.2051.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Thu, 2005-11-03 at 10:32 -0500, Tom Lane wrote:
> I'd feel a lot happier about this if we could keep the dynamic range
> up to, say, 10^512 so that it's still true that NUMERIC can be a
> universal parse-time representation. That would also make it even
> more unlikely that anyone would complain about loss of functionality.
>
> To do that we'd need 8 bits for weight (-128..127 for a base-10K
> exponent is enough) but we need 9 bits for dscale which does not
> quite fit. I think we could make it go by cramming the sign and
> the high-order dscale bit into the first NumericDigit --- the
> digit itself can only be 0..9999 so there are a couple of bits
> to spare. This probably *would* slow down packing and unpacking of
> numerics, but just by a couple lines of C. Arguably the net reduction
> in I/O costs would justify that.

I've got a working version of the code using the above scheme, with
these additional wrinkles:

NaN is indicated by weight=-128, giving a dynamic range of 10^508.

Zeroes are fully compressed, except when the Scale > 255. In that case,
the first digit is present to signify the presence of the high order
Scale bit.

Comments?

Once 8.1 is released, I'll go back and see if I can improve the coding
in a few days with fresh eyes, then submit a patch.

Best Regards, Simon Riggs

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2005-11-06 09:00:05 Re: [HACKERS] insert performance for win32
Previous Message Tom Lane 2005-11-05 21:47:41 Last chance to defend RTREE index access method

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-11-06 16:26:39 Re: Reducing the overhead of NUMERIC data
Previous Message Harald Fuchs 2005-11-05 15:34:56 Re: Reducing the overhead of NUMERIC data