Re: Reducing the overhead of NUMERIC data - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Reducing the overhead of NUMERIC data
Date
Msg-id 22263.1131031923@sss.pgh.pa.us
Whole thread Raw
In response to Re: Reducing the overhead of NUMERIC data  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Reducing the overhead of NUMERIC data  (Simon Riggs <simon@2ndquadrant.com>)
Re: Reducing the overhead of NUMERIC data  ("Jim C. Nasby" <jnasby@pervasive.com>)
Re: Reducing the overhead of NUMERIC data  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> On Thu, 3 Nov 2005, Simon Riggs wrote:
>>> At the moment we've established we can do this fairly much for free.

> Agreed.  With the proposal, we are saving perhaps 5% storage space for
> numeric fields, but are adding code complexity and reducing its possible
> precision.

Having to invent UNKNOWNNUMERIC is hardly what I'd call "for free".
That takes it out of the realm of being a small localized project.
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.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Reducing the overhead of NUMERIC data
Next
From: Alvaro Herrera
Date:
Subject: Re: slru.c race condition (was Re: TRAP: FailedAssertion("!((itemid)->lp_flags