pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Kenneth Gonsalves <lawgon@thenilgiris.com>
Cc: Richard Huxton <dev@archonet.com>
Cc: weberp@paradise.net.nz
Cc: pgsql-sql@postgresql.org
Subject: Re: Query performance problem
Date: Fri, 18 Mar 2005 05:19:28 -0800 (PST)
Message-ID: <20050318051614.Q61964@megazone.bigpanda.com> (raw)
In-Reply-To: <200503181049.47566.lawgon@thenilgiris.com>
References: <200503172120.20676.weberp@paradise.net.nz>
	<200503171801.19412.lawgon@thenilgiris.com>
	<42398EB9.2050707@archonet.com>
	<200503181049.47566.lawgon@thenilgiris.com>

On Fri, 18 Mar 2005, Kenneth Gonsalves wrote:

> On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote:
>
> > Not necessarily. NOT NULL here helps to ensure you can add values
> > together without the risk of a null result. There are plenty of
> > "amount" columns that should be not-null (total spent, total
> > ordered etc).
>
> that makes sense - but is it necessary to have a not null constraint
> when there is a default value?

It's also an added check which prevents you from explicitly setting the
value to NULL in an insert or update, since
"insert into foo(col1) values (NULL);" shouldn't insert the default value
into col1.  This is relatively minor generally, but if you have queries
whose behavior is broken by NULLs (things using IN/NOT IN for example)
it's better to be safe.




view thread (10+ messages)  latest in thread

Message-ID: <20050318051614.Q61964@megazone.bigpanda.com>
Permalink:  ../20050318051614.Q61964@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20050318051614.Q61964@megazone.bigpanda.com

 · 

reply

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-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, lawgon@thenilgiris.com, dev@archonet.com, weberp@paradise.net.nz
  Subject: Re: Query performance problem
  In-Reply-To: <20050318051614.Q61964@megazone.bigpanda.com>

* 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