Re: Storage cost of a null column - Mailing list pgsql-general

From Tom Lane
Subject Re: Storage cost of a null column
Date
Msg-id 3996.1080934558@sss.pgh.pa.us
Whole thread Raw
In response to Storage cost of a null column  (Randall Skelton <skelton@brutus.uwaterloo.ca>)
Responses Re: Storage cost of a null column
List pgsql-general
Randall Skelton <skelton@brutus.uwaterloo.ca> writes:
> What is the storage cost of a null entry in a column?

If you have even one, all the rest in that row are free, so your scheme
sounds reasonable.

Null columns are simply not stored.  There is a bitmap at the start of
the row with one bit per column, indicating which ones are null or not
null.  However we omit the bitmap if all columns are nonnull in a
particular row.  So it's reasonable to consider the cost of the first
null as being the size of the bitmap (N bits for an N-column table,
rounded up).  The rest are free.

>  Because of this, we made a decision that we would have hundreds of 2
> column tables (timestamp, value) and use unions, intersections, and

Narrow tables are a dead loss if you're concerned about storage space
--- you'll get eaten by the per-row overhead, which is a minimum of 28
bytes per row.

            regards, tom lane

pgsql-general by date:

Previous
From: John DeSoi
Date:
Subject: Re: row-level security model
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Storage cost of a null column