Hannu Krosing <hannu@skype.net> writes:
> would adding this -
> first byte 0xxxxxxx ---- field length 1 byte, exactly that value
> first byte 10xxxxxx ---- 0xxxxxx data bytes follow
> first byte 110xxxxx -- xxxxx xxxxxxxx data bytes to follow
> first byte 111xxxxx -- xxxxx xxxxxxxx xxxxxxxx xxxxxxxx bytes t.flw
> be too expensive ?
What's the point? Unless there's provision for TOAST, you can't put
arbitrarily long strings on disk anyway, so I don't see what this
datatype can do that is much better than the simpler version. If you
try to fit TOAST in, then you are back to exactly the var-length-varlena
proposals upthread.
To me the only really compelling argument for worrying about the size
of the header is for fields that are certain to be short, such as
poor-mans-enumerated-type strings, part numbers, etc. The
zero-or-one-byte header approach seems to handle that use-case just
fine. I think more complicated approaches are going to add lots of
code and cycles for only very marginal gains.
regards, tom lane