Re: Null integer columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeffrey Tenny <jeffrey(dot)tenny(at)comcast(dot)net>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Null integer columns
Date: 2005-01-08 21:55:49
Message-ID: 8512.1105221349@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jeffrey Tenny <jeffrey(dot)tenny(at)comcast(dot)net> writes:
> What are the performance tradeoffs (storage space, query speed) of using
> a NULL enabled column versus a NOT-NULL column with a sentinel integer
> value?
> Not that it matters, but in the event where the column values matter,
> the numberic value is a foreign key. Advice on that welcome too.

In that case you want to use NULL, because the foreign key mechanism
will understand that there's no reference implied. With a sentinel
value you'd have to have a dummy row in the master table --- which will
cause you enough semantic headaches that you don't want to go there.

The performance difference could go either way depending on a lot of
other details, but it will be insignificant in any case. Don't screw up
your database semantics for it.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Guenzl, Martin 2005-01-09 04:44:30 Help with EXPLAIN ANALYZE runtimes
Previous Message Jeffrey Tenny 2005-01-08 21:07:00 Null integer columns