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@momjian.us EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +