X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A71143A52BA for ; Sat, 8 Jan 2005 21:55:57 +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 63210-07 for ; Sat, 8 Jan 2005 21:55:48 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6A8B23A52A9 for ; Sat, 8 Jan 2005 21:55:50 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j08Ltnwu008513; Sat, 8 Jan 2005 16:55:49 -0500 (EST) To: Jeffrey Tenny Cc: pgsql-performance@postgresql.org Subject: Re: Null integer columns In-reply-to: <41E04B74.8050609@comcast.net> References: <41E04B74.8050609@comcast.net> Comments: In-reply-to Jeffrey Tenny message dated "Sat, 08 Jan 2005 16:07:00 -0500" Date: Sat, 08 Jan 2005 16:55:49 -0500 Message-ID: <8512.1105221349@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/92 X-Sequence-Number: 9782 Jeffrey Tenny writes: > What are the performance tradeoffs (storage space, query speed) of using > a NULL enabled column versus a NOT-NULL column with a sentinel integer > value? > Not that it matters, but in the event where the column values matter, > the numberic value is a foreign key. Advice on that welcome too. In that case you want to use NULL, because the foreign key mechanism will understand that there's no reference implied. With a sentinel value you'd have to have a dummy row in the master table --- which will cause you enough semantic headaches that you don't want to go there. The performance difference could go either way depending on a lot of other details, but it will be insignificant in any case. Don't screw up your database semantics for it. regards, tom lane