Skip site navigation (1) Skip section navigation (2)

Re: How are null's stored?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: jim(at)nasby(dot)net, pgsql-performance(at)postgresql(dot)org
Subject: Re: How are null's stored?
Date: 2003-05-12 20:44:43
Message-ID: 200305121344.43288.josh@agliodbs.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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


In response to

Responses

pgsql-performance by date

Next:From: Andrew SullivanDate: 2003-05-12 21:04:24
Subject: Re: How are null's stored?
Previous:From: Alfranio JuniorDate: 2003-05-12 19:35:24
Subject: PERFORMANCE and SIZE

pgsql-hackers by date

Next:From: Andrew SullivanDate: 2003-05-12 21:04:24
Subject: Re: How are null's stored?
Previous:From: Jim C. NasbyDate: 2003-05-12 19:01:56
Subject: How are null's stored?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group