Re: How are null's stored? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: How are null's stored?
Date
Msg-id 200305121344.43288.josh@agliodbs.com
Whole thread Raw
In response to How are null's stored?  ("Jim C. Nasby" <jim@nasby.net>)
Responses Re: How are null's stored?
List pgsql-performance
Jim,

> I have a 40M row table I need to import data into, then use to create a
> bunch of more normalized tables. Right now all fields are varchar, but
> I'm going to change this so that fields that are less than a certain
> size are just char. Question is, how much impact is there from char
> being nullable vs. not nullable? src/include/access/htup.h indicates
> that nulls are stored in a bitmap, so I'd suspect that I should see a
> decent space savings from not having to include length information all
> the time... (most of these small fields are always the same size no
> matter what...)

This is moot.   PostgreSQL stores CHAR(x), VARCHAR, and TEXT in the same
internal format, which includes length information in the page header.   So
you save no storage space by converting to CHAR(x) ... you might even make
your tables *larger* because of the space padding.

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


pgsql-performance by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: How are null's stored?
Next
From: "Ryan"
Date:
Subject: Re: How are null's stored?