Re: more numeric stuff

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: more numeric stuff
Date: 2010-08-04 23:27:57
Message-ID: 17231.1280964477@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Wed, Aug 4, 2010 at 4:07 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2010-08-04 23:43:09 Re: Two different methods of sneaking non-immutable data into an index
Previous Message Robert Haas 2010-08-04 23:19:01 Re: [HACKERS] Drop one-argument string_agg? (was Re: string_agg delimiter having no effect with order by)