Re: CHAR(N) storage requirement

Поиск
Список
Период
Сортировка
От David Garamond
Тема Re: CHAR(N) storage requirement
Дата
Msg-id 40017F05.8040307@zara.6.isreserved.com
обсуждение исходный текст
Ответ на Re: CHAR(N) storage requirement  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: CHAR(N) storage requirement  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-general
Peter Eisentraut wrote:
>>Is it the 4+N (aka. same as VARCHAR(n)) or is it N? Sorry, it was
>>100% not clear for me after reading the docs, though the docs imply
>>the first: "The storage requirement for data of these types is 4
>>bytes plus the actual string, and in case of character plus the
>>padding."
>
> Storing varchar(n) takes 4 bytes plus as many bytes as are required to
> store the actual string.  This may be more or less then "n".
>
> Storing char(n) takes 4 bytes plus as many bytes are are required to
> store the actual string, plus n - length(value) bytes for padding
> spaces.  This is at least "n" bytes.

I see. Then there is no real benefits at all in using CHAR(N) in
PostgreSQL, is that right? I wonder why there is no storage saving done
by PostgreSQL for CHAR compared to VARCHAR (since the string length of
CHAR field will be the same for all rows)... Or perhaps I can use array
or CREATE TYPE to achieve this (that is, minimizing storage to only "n"
bytes to store CHAR(n)). Assuming no multibyte/Unicode, only US-ASCII
values.

--
dave


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: CHAR(N) storage requirement
Следующее
От: Sai Hertz And Control Systems
Дата:
Сообщение: Re: IEEE 754 Conclusion