Re: byte-size of column values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dominique Devienne <ddevienne(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: byte-size of column values
Date: 2022-10-19 13:34:20
Message-ID: 2840902.1666186460@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dominique Devienne <ddevienne(at)gmail(dot)com> writes:
> On Tue, Oct 18, 2022 at 6:04 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2022-10-19 13:57:53 Re: Is this error expected ?
Previous Message Dominique Devienne 2022-10-19 13:32:50 Re: How to store "blobs" efficiently for small and large sizes, with random access