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-03 20:12:46
Message-ID: 1131048766.8300.2011.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:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-11-03 20:19:41 Re: pgsql: Rename the members of CommandDest enum so
Previous Message Andrew - Supernews 2005-11-03 19:41:18 Re: Reducing the overhead of NUMERIC data

Browse pgsql-patches by date

  From Date Subject
Next Message Jim C. Nasby 2005-11-03 21:34:24 Re: slru.c race condition (was Re: TRAP: FailedAssertion("!((itemid)->lp_flags
Previous Message Alvaro Herrera 2005-11-03 20:08:17 Re: Limit usage of tcop/dest.h