Re: Query performance problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>
Cc: Richard Huxton <dev(at)archonet(dot)com>, weberp(at)paradise(dot)net(dot)nz, pgsql-sql(at)postgresql(dot)org
Subject: Re: Query performance problem
Date: 2005-03-18 13:19:28
Message-ID: 20050318051614.Q61964@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gary Stainburn 2005-03-18 13:25:23 best way to swap two records (computer details)
Previous Message PFC 2005-03-18 09:10:10 Re: Query performance problem