X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BA865547B for ; Fri, 18 Mar 2005 13:29:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34309-01 for ; Fri, 18 Mar 2005 13:29:40 +0000 (GMT) Received: from pd6mo1no.prod.shaw.ca (idcmail-mo2no.cg.shawcable.net [64.59.134.9]) by svr1.postgresql.org (Postfix) with ESMTP id 5CC4352A52 for ; Fri, 18 Mar 2005 13:29:39 +0000 (GMT) Received: from pd8mr8no.prod.shaw.ca (pd8mr8no-qfe2.prod.shaw.ca [10.0.144.229]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IDJ00GOLUTIZZ00@l-daemon> for pgsql-sql@postgresql.org; Fri, 18 Mar 2005 06:29:42 -0700 (MST) Received: from pn7ml3no.prod.shaw.ca ([10.0.149.112]) by pd8mr8no.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0IDJ0025PUTILQK0@pd8mr8no.prod.shaw.ca> for pgsql-sql@postgresql.org; Fri, 18 Mar 2005 06:29:42 -0700 (MST) Received: from Dell4500 (S01060004236fc1f7.wp.shawcable.net [24.77.13.13]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with SMTP id <0IDJ00328UTEDF@l-daemon> for pgsql-sql@postgresql.org; Fri, 18 Mar 2005 06:29:42 -0700 (MST) Date: Fri, 18 Mar 2005 07:29:54 -0600 From: George Weaver Subject: Re: Query performance problem To: Kenneth Gonsalves , Richard Huxton Cc: weberp@paradise.net.nz, pgsql-sql@postgresql.org Message-id: <002101c52bbe$94689670$6400a8c0@Dell4500> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Mailer: Microsoft Outlook Express 6.00.2900.2527 Content-type: text/plain; format=flowed; charset=utf-8; reply-type=original Content-transfer-encoding: 8BIT X-Priority: 3 X-MSMail-priority: Normal References: <200503172120.20676.weberp@paradise.net.nz> <200503171801.19412.lawgon@thenilgiris.com> <42398EB9.2050707@archonet.com> <200503181049.47566.lawgon@thenilgiris.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.481 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200503/259 X-Sequence-Number: 20738 Only specifying a default value does not prevent a NULL from being entered either through accident or ignorance: jan28-05=# create table test (foo text, foo1 int4 default(0)); CREATE TABLE jan28-05=# insert into test values('a',1); INSERT 98685 1 jan28-05=# insert into test values('b',4); INSERT 98686 1 jan28-05=# insert into test values('c',NULL); INSERT 98687 1 jan28-05=# insert into test values('d'); INSERT 98688 1 jan28-05=# select * from test; foo | foo1 -----+------ a | 1 b | 4 c | d | 0 (4 rows) George ----- Original Message ----- From: "Kenneth Gonsalves" To: "Richard Huxton" Cc: ; Sent: Thursday, March 17, 2005 11:19 PM Subject: Re: [SQL] Query performance problem 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? -- regards kg http://www.livejournal.com/users/lawgon tally ho! http://avsap.sourceforge.net ಇಂಡ್ಲಿನಕ್ಸ வாழ்க! ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)