From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dominique Devienne <ddevienne@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: byte-size of column values
Date: Wed, 19 Oct 2022 09:34:20 -0400
Message-ID: <2840902.1666186460@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFCRh-8vRSkJ9T1oTM6m9f9nPd9Af+r3j2a4VNT+kDBnryX5CA@mail.gmail.com>
References: <CAFCRh-8gUgsZt8Yg7c_k2Es7wPPQwhqghGJO3V7azcSFfj+BRg@mail.gmail.com>
<2655106.1666109088@sss.pgh.pa.us>
<CAFCRh-8vRSkJ9T1oTM6m9f9nPd9Af+r3j2a4VNT+kDBnryX5CA@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, ddevienne@gmail.com
Subject: Re: byte-size of column values
In-Reply-To: <2840902.1666186460@sss.pgh.pa.us>
References: <CAFCRh-8gUgsZt8Yg7c_k2Es7wPPQwhqghGJO3V7azcSFfj+BRg@mail.gmail.com> <2655106.1666109088@sss.pgh.pa.us> <CAFCRh-8vRSkJ9T1oTM6m9f9nPd9Af+r3j2a4VNT+kDBnryX5CA@mail.gmail.com> <2840902.1666186460@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox