Re: Fixed length data types issue

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: mark(at)mark(dot)mielke(dot)cc, Peter Eisentraut <peter_e(at)gmx(dot)net>, Gregory Stark <gsstark(at)mit(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fixed length data types issue
Date: 2006-09-08 19:15:18
Message-ID: 200609081915.k88JFI408663@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
-- Start of PGP signed section.
> On Fri, Sep 08, 2006 at 09:28:21AM -0400, mark(at)mark(dot)mielke(dot)cc wrote:
> > > But that won't help in the example you posted upthread, because char(N)
> > > is not fixed-length.
> >
> > It can be fixed-length, or at least, have an upper bound. If marked
> > up to contain only ascii characters, it doesn't, at least in theory,
> > and even if it is unicode, it's not going to need more than 4 bytes
> > per character. char(2) through char(16) only require 4 bits to
> > store the length header, leaving 4 bits for encoding information.
> > bytea(2) through bytea(16), at least in theory, should require none.
>
> If your talking about an upper-bound, then it's not fixed length
> anymore, and you need to expend bytes storing the length. ASCII bytes
> only take one byte in most encodings, include UTF8.
>
> Doodling this morning I remember why the simple approach didn't work.
> If you look at the varlena header, 2 bits are reserved. Say you take
> one bit to indicate "short header". Then lengths 0-31 bytes can be
> represented with a one byte header, yay!
>
> However, now you only have enough bits leftover to store 29 bits for
> the length, so we've just cut the maximum datum size from 1GB to 512MB.
> Is that a fair trade? Probably not, so you'd need a more sophisticated
> scheme.

I was hoping we could have both bits true mean short header, but that is
also used by our system to indicate compressed and TOAST usage. For
testing, I would just grab a bit and see how thing go.

--
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

Browse pgsql-hackers by date

  From Date Subject
Next Message Gevik Babakhani 2006-09-08 19:18:20 Proposal for GUID datatype
Previous Message Andrew Dunstan 2006-09-08 19:08:18 Re: Fixed length data types issue