Re: size of NULL field? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: size of NULL field?
Date
Msg-id 200204151933.g3FJXT912721@candle.pha.pa.us
Whole thread Raw
In response to Re: size of NULL field?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Tom Lane wrote:
> nazgul@punkass.spam (nazgul) writes:
> > Hi, I'm wondering how much storage space a NULL value takes up?
>
> None.
>
> However, as soon as you have any NULLs in a particular table row, the
> row needs to store a NULL-value bitmap, which has one bit per table
> column to show which ones are nulls.  So you could say that the first
> NULL in a given row costs you 4 bytes (more if you have > 32 columns).
> Additional NULLs in the row are free.

Oh, I didn't realize the size of the NULL bitmask was zero if no nulls
exist.  Nice.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: psql and passwords
Next
From: Neil Conway
Date:
Subject: Re: string encryption