Re:

Поиск
Список
Период
Сортировка
От strange@nsk.yi.org
Тема Re:
Дата
Msg-id 20020704195016.A12936@nsk.yi.org
обсуждение исходный текст
Ответ на ...  (Francisco Reyes <lists@natserv.com>)
Список pgsql-general
On Thu, Jul 04, 2002 at 02:06:31PM -0400, Francisco Reyes wrote:
> On the FAQ we have:
>
> CHAR() is best when storing strings that are usually the
> same length.  VARCHAR() is best when storing variable-length strings,
> but you want to limit how long a string can be.  TEXT is for strings
> of unlimited length, maximum 1 gigabyte.  BYTEA is for storing
> binary data, particularly values that include NULL bytes.
>
>
> How much space does "NULL" takes on a varchar.

From http://developer.postgresql.org/docs/postgres/datatype.html:
 The storage requirement for data of these types is 4 bytes plus the
actual string, and in case of character plus the padding.

So at least 4 bytes. Another bit in the table will be used to indicate
that it's a NULL value, AFAIK, but it will exist anyway.

> I have a table where possibly less than 40% of the records will have a
> value. I am wondering if I should go with a second table for those that
> have the values or if NULL is small enough that it won't be much an
> overhead for the possibly 60% instances when the column would be empty.

If your overhead is about space, I don't think you'd win much, as you'd
probably need an indicator of whether the value exists and its place in
the other table anyway.

And you'll lose convenience also.

Regards,
Luciano Rocha



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: repeatable crash generating two column index
Следующее
От: Manfred Koizar
Дата:
Сообщение: Re: