From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeffrey Tenny <jeffrey.tenny@comcast.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Null integer columns
Date: Sat, 08 Jan 2005 16:55:49 -0500
Message-ID: <8512.1105221349@sss.pgh.pa.us> (raw)
In-Reply-To: <41E04B74.8050609@comcast.net>
References: <41E04B74.8050609@comcast.net>
Jeffrey Tenny <jeffrey.tenny@comcast.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, jeffrey.tenny@comcast.net
Subject: Re: Null integer columns
In-Reply-To: <8512.1105221349@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox