Re: Fixed length data types issue

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Gregory Stark <stark(at)enterprisedb(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>
Subject: Re: Fixed length data types issue
Date: 2006-09-07 18:35:12
Message-ID: 200609071835.k87IZC809710@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
> Gregory Stark wrote:
> > By my count postgres would use 154 bytes for this record. Whereas in
> > fact there's no need for it to take more than 87 bytes. Almost 100%
> > overhead for varattlen headers and the padding they necessitate.
>
> The thing is, 100% extra space is cheap, but the processing power for
> making the need for that extra space go away is not.

I think it would be good to see if we can extend the varlena data types
to support a shorter header for storing short byte values. Looking at
the header now we have:

#define VARATT_FLAG_EXTERNAL 0x80000000
#define VARATT_FLAG_COMPRESSED 0x40000000
#define VARATT_MASK_FLAGS 0xc0000000
#define VARATT_MASK_SIZE 0x3fffffff

#define VARATT_SIZEP(_PTR) (((varattrib *)(_PTR))->va_header)

so there is precedent for overloading that header, but currently all the
headers are four bytes. The big question is can a bit be allocated to
indicate a short byte header is being used? Can we do this with minimal
performance impact for non-short values?

One test would be to adjust the masks above to assign one bit to be the
"I am a short value" header, and I think that leaves you with 5 bits ==
32, which is probably enough for a test.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2006-09-07 18:41:12 Re: getting access to gborg, specifically the jdbc CVS
Previous Message Peter Eisentraut 2006-09-07 18:05:47 Re: Fixed length data types issue