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

Re: NULL saves disk space?

From: David Johnston <polobo(at)yahoo(dot)com>
To: Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: NULL saves disk space?
Date: 2011-04-29 14:40:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
I figure you have a reason for considering using nulls but since you didn't explain the underlying problem you are trying to solve it is hard to comment or consider.  If you share there may someone who can provide a solution that doesn't violate best practices and common sense.

David J.

On Apr 29, 2011, at 10:03, Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com> wrote:

> On Thu, Apr 28, 2011 at 10:59 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
>> On Wed, Apr 27, 2011 at 5:24 PM, Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com> wrote:
>>> Possibly a dumb question but there isn't much about this.
>>> I have some BOOLEAN columns. 90% of the cases of the columns is FALSE. Do I
>>> save disk space by having them as NULL instead of FALSE? So my application
>>> would have conditional code for NULL and TRUE, instead of FALSE and TRUE.
>>> Thanks...
>> Yes, NULL values take no additional space, but the row needs a null
>> bitmap so it is possible that if this was the only NULL then it could
>> occupy more space.
>> If you have multiple columns, then you should use NULLs.
> Thanks Simon. (And others for good advice, but that was not my
> question. I already know using boolean as TRUE/FALSE is sensible. But
> I have a peculiar reason for asking what I am.)
> Simon, if I understand you correctly -- more than one column in a row
> should have NULL for NULL to be useful in saving space? What if in a
> row there are many columns but only one will be NULL?
> Thanks
> -- 
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:

In response to

pgsql-general by date

Next:From: Vick KheraDate: 2011-04-29 14:47:01
Subject: Re: Partitioning an existing table
Previous:From: Phoenix KiulaDate: 2011-04-29 14:03:06
Subject: Re: NULL saves disk space?

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