On Thu, 2005-11-03 at 10:32 -0500, Tom Lane wrote:
> 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.
This sounds a much better solution and the code neater too.
This still would be a very small patch, not very intrusive at all.
I'll have a hack at this now.
Best Regards, Simon Riggs