X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 36AAA9FA176 for ; Fri, 19 May 2006 05:38:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 14554-10 for ; Fri, 19 May 2006 05:38:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 96BE19F9429 for ; Fri, 19 May 2006 05:38:26 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (T856d.t.pppool.de [89.55.133.109]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 9183365836; Fri, 19 May 2006 10:39:41 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 199101853CA67; Fri, 19 May 2006 10:38:44 +0200 (CEST) Message-ID: <446D8413.8060303@logix-tt.com> Date: Fri, 19 May 2006 10:38:43 +0200 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andreas Joseph Krogh Cc: pgsql-sql@postgresql.org Subject: Re: Constraint question References: <200605181541.54299.andreak@officenet.no> <446CA301.20305@logix-tt.com> <200605182105.55753.andreak@officenet.no> In-Reply-To: <200605182105.55753.andreak@officenet.no> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/152 X-Sequence-Number: 25183 Hi, Andreas, Andreas Joseph Krogh wrote: >>CREATE UNIQUE INDEX foo ON onp_crm_businessfield_company(company_id) >>WHERE is_prefferred; > I also figured out that an index like this also works: > UNIQUE(company_id, is_preferred) > This works because NULL = NULL is false. But I guess your solution is cleaner. Yes, it works, but it needs more disk space (it has to index all rows, and it needs to save both columns), and thus is slower, too. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org