Re: Query performance problem - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Query performance problem
Date
Msg-id 20050318051614.Q61964@megazone.bigpanda.com
Whole thread Raw
In response to Re: Query performance problem  (Kenneth Gonsalves <lawgon@thenilgiris.com>)
List pgsql-sql
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.



pgsql-sql by date:

Previous
From: PFC
Date:
Subject: Re: Query performance problem
Next
From: George Weaver
Date:
Subject: Re: Query performance problem