Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 97787B5DC02 for ; Tue, 23 Aug 2011 07:35:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 47247-05 for ; Tue, 23 Aug 2011 10:35:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 030D8B5D803 for ; Tue, 23 Aug 2011 07:35:07 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QvoK2-000338-T2 for pgsql-sql@postgresql.org; Tue, 23 Aug 2011 12:35:06 +0200 Received: from ip-118-90-127-15.xdsl.xnet.co.nz ([118.90.127.15]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Aug 2011 12:35:06 +0200 Received: from jasen by ip-118-90-127-15.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Aug 2011 12:35:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: exclusion constraint for ranges of IP Date: 23 Aug 2011 10:31:42 GMT Organization: Dis (not Dat) Organisation Lines: 23 Message-ID: References: <0207A022-1ABB-4CCA-B483-869756C47D0B@unicell.co.il> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-127-15.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.373 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.473 X-Spam-Level: X-Archive-Number: 201108/94 X-Sequence-Number: 35762 On 2011-08-23, Herouth Maoz wrote: > EXCLUDE USING GIST ( customer_id WITH =, is_default WITH AND ) > Basically, each customer can have several rows in this table, but only = > one per customer is allowed to have is_default =3D true. Is this exclude = > constraint correct? I don't really understand exclude, but instead of EXCLUDE... I would do CREATE UNIQUE INDEX "invoice_definitions-unique-default" ON invoice_definitions(customer_id) WHERE is_default; Which would create a smaller (and probably faster) BTREE index containing only the rows with is_default true. There seems to be no way to create this in the create-table command. (using 8.4 here) -- ⚂⚃ 100% natural