Re: byte-size of column values - Mailing list pgsql-general

From Tom Lane
Subject Re: byte-size of column values
Date
Msg-id 2840902.1666186460@sss.pgh.pa.us
Whole thread Raw
In response to Re: byte-size of column values  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
Dominique Devienne <ddevienne@gmail.com> writes:
> On Tue, Oct 18, 2022 at 6:04 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Thus, there's always a header to store the actual length.  That can
>> be either 1 or 4 bytes (I think the doc you are looking at might be
>> a little out of date on that point).

> Even the doc on v15 (or devel) still says 5-to-8.
> https://www.postgresql.org/docs/15/datatype-bit.html

Oh, if you're thinking about bit rather than string types,
that's correct: in addition to the overall-field-width
header (1 or 4 bytes) there's a length-in-bits field
(always 4 bytes), then the bits themselves.  The overall
width is clearly insufficient to know how many bits are
valid in the last byte, so some additional storage is
necessary.  This could have been done in a more compact
way no doubt, but we aren't likely to change it now.

            regards, tom lane



pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Re: How to store "blobs" efficiently for small and large sizes, with random access
Next
From: Ron
Date:
Subject: Re: Is this error expected ?