Re: byte-size of column values

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: byte-size of column values
Дата
Msg-id 2655106.1666109088@sss.pgh.pa.us
обсуждение исходный текст
Ответ на byte-size of column values  (Dominique Devienne <ddevienne@gmail.com>)
Ответы Re: byte-size of column values  (Dominique Devienne <ddevienne@gmail.com>)
Список pgsql-general
Dominique Devienne <ddevienne@gmail.com> writes:
> Hi. I'm surprised by the result for bit(3) and char, when calling
> pg_column_size().

> Why 6, instead of 1? The doc does mention 5-8 bytes overhead, but I
> expected those for varying bit, not fixed-sized bit typed values. How
> come?

Your expectation is incorrect.  Postgres always treats these types
as variable-length, whether or not the column has a length constraint.
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).

Because of the popularity of variable-width character encodings,
a column declared as N characters wide isn't necessarily a fixed
number of bytes wide, making it a lot less useful than you might
think to have optimizations for fixed-width storage.  Between that
and the fact that most Postgres developers regard CHAR(N) as an
obsolete hangover from the days of punched cards, no such
optimizations have been attempted.

            regards, tom lane



В списке pgsql-general по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: byte-size of column values
Следующее
От: Ravi Krishna
Дата:
Сообщение: COMMIT IN STORED PROCEDURE WHILE IN A LOOP