Re: size of NULL field?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: nazgul(at)punkass(dot)spam (nazgul)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: size of NULL field?
Date: 2002-04-15 15:10:10
Message-ID: 23186.1018883410@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

nazgul(at)punkass(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Loftis 2002-04-15 15:16:38 Re: Why does postgres not take into account my index on a bigint column ?
Previous Message Tom Lane 2002-04-15 15:05:48 Re: Query planner quirk?