Re: more numeric stuff - Mailing list pgsql-hackers

From Tom Lane
Subject Re: more numeric stuff
Date
Msg-id 17231.1280964477@sss.pgh.pa.us
Whole thread Raw
In response to Re: more numeric stuff  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: more numeric stuff  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Wed, Aug 4, 2010 at 4:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> This would be good, but I'm not sure how to do it. �The main problem
>> again is NumericDigit alignment. �Only about half the time is the digit
>> array going to be aligned the way you need, so that puts a real crimp
>> in the possible win. �(In fact, if we assume the previous field is more
>> than byte aligned and the toast header is one byte, then the digit array
>> is *never* properly aligned on disk :-(

> This is another reason why I think a 1-byte numeric header would be
> good to have.

Hmm.  That's a good point --- 1-byte toast header plus 1-byte numeric
header would leave you correctly aligned, anytime the previous field
didn't end on an odd byte boundary.  So maybe the combination of both
things would have enough synergy to be worth the trouble.  Still,
it seems like it'd be quite messy to deal with 1-byte header followed
by NumericDigits without any padding ... there'd be no way to declare
that as a C struct, for sure.  Have you got a plan for what this would
actually look like in code?

Also, maybe this idea should supersede the one with two-byte numeric
header.  I'm not sure it's worth having three variants, and we are
not at all committed to the two-byte version yet.

>> I don't think this would win unless we went to 32-bit NumericDigit,
>> which is a problem from the on-disk-compatibility standpoint,

> This would increase the average size of a Numeric value considerably,
> so it would be a very BAD thing IMO.

Oh, I certainly wasn't advocating for doing that ;-)
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Drop one-argument string_agg? (was Re: [BUGS] string_agg delimiter having no effect with order by)
Next
From: Merlin Moncure
Date:
Subject: Re: Two different methods of sneaking non-immutable data into an index