Re:

From: strange(at)nsk(dot)yi(dot)org
To: Francisco Reyes <lists(at)natserv(dot)com>
Cc: pgsql General List <pgsql-general(at)postgresql(dot)org>
Subject: Re:
Date: 2002-07-04 18:50:16
Message-ID: 20020704195016.A12936@nsk.yi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • at 2002-07-04 18:06:31 from Francisco Reyes

Browse pgsql-general by date

  From Date Subject
Next Message Manfred Koizar 2002-07-04 18:50:34 Re:
Previous Message Tom Lane 2002-07-04 18:47:44 Re: repeatable crash generating two column index