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 10F6955112 for ; Thu, 17 Mar 2005 14:05:56 +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 42135-07 for ; Thu, 17 Mar 2005 14:05:47 +0000 (GMT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 32966566A4 for ; Thu, 17 Mar 2005 14:05:46 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 4.42) id 1DBvb2-0007Yu-Ge; Thu, 17 Mar 2005 14:03:32 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id DBAAE15938; Thu, 17 Mar 2005 14:05:47 +0000 (GMT) Message-ID: <42398EB9.2050707@archonet.com> Date: Thu, 17 Mar 2005 14:05:45 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kenneth Gonsalves Cc: weberp@paradise.net.nz, pgsql-sql@postgresql.org Subject: Re: Query performance problem References: <200503172120.20676.weberp@paradise.net.nz> <200503171801.19412.lawgon@thenilgiris.com> In-Reply-To: <200503171801.19412.lawgon@thenilgiris.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/244 X-Sequence-Number: 20723 Kenneth Gonsalves wrote: > On Thursday 17 Mar 2005 1:50 pm, Phil Daintree wrote: > > >>CREATE TABLE chartdetails ( >> accountcode integer DEFAULT 0 NOT NULL, >> period integer DEFAULT 0 NOT NULL, >> budget double precision DEFAULT (0)::double precision NOT NULL, >> actual double precision DEFAULT (0)::double precision NOT NULL, >> bfwd double precision DEFAULT (0)::double precision NOT NULL, >> bfwdbudget double precision DEFAULT (0)::double precision NOT >>NULL ); > > > although may be not relevant to your question, as i have noticed this > before with mysql 'sql', what is the point of having a NOT NULL field > that defaults to 0? the whole idea of a NOT NULL field is to have the > value filled in compulsorily and having a default of 0 or '' defeats > the purpose 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). -- Richard Huxton Archonet Ltd