From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Francisco Reyes <lists(at)natserv(dot)com>, pgsql General List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: |
Date: | 2002-07-04 19:23:36 |
Message-ID: | 200207041923.g64JNaT00892@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
> Francisco Reyes <lists(at)natserv(dot)com> writes:
> > How much space does "NULL" takes on a varchar.
>
> This is getting to be a FAQ itself --- Bruce, would you like to
> add something along the following lines to the FAQ?
>
> Q. How much space does a NULL take?
>
> A. None; it's not stored. However, if a table row contains any NULLs
> then it must include a "nulls bitmap" that shows which columns are NULL.
> The bitmap has one bit per table column. The bitmap is omitted if the
> row contains no NULLs at all. So, in practice the first NULL you put in
> a row costs number-of-columns bits. Any additional NULLs in the same
> row are completely free as far as storage space is concerned.
>
> Also, the space effectively occupied by the bitmap depends on alignment
> considerations, because the total size of the row header and bitmap
> will be rounded up to a MAXALIGN boundary (either 4 or 8 bytes on
> most hardware). In 7.3 it's likely that a bitmap for a row of up to
> 8 columns will be completely free, because the rounded-up header size
> will be the same with or without it.
I added this to the disk space FAQ item. Let's see how that works:
<P><SMALL>NULL</SMALL>s are stored in bitmaps, so they
use very little space.</P>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Manuel W. | 2002-07-04 22:08:46 | Postgre vs MySQL |
Previous Message | Jeff Glatt is a Dumbass | 2002-07-04 19:17:56 | Re: I am being interviewed by OReilly |