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

From Tom Lane
Subject Re: size of NULL field?
Date
Msg-id 23186.1018883410@sss.pgh.pa.us
Whole thread Raw
In response to size of NULL field?  (nazgul@punkass.spam (nazgul))
Responses Re: size of NULL field?
List pgsql-general
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.

            regards, tom lane

PS: if you're on a machine where MAXALIGN is 8, the cost quantum is
8 bytes not 4.  But I think it's usually 4 on peecee hardware.

pgsql-general by date:

Previous
From: Lamar Owen
Date:
Subject: Re: I would preffer that postgresql start with the flag -i
Next
From: Tom Lane
Date:
Subject: Re: I: Migrating a very large db