pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org
Subject: Re: exclusion constraint for ranges of IP
Date: 23 Aug 2011 10:31:42 GMT
Message-ID: <j2vvie$u2i$2@reversiblemaps.ath.cx> (raw)
References: <CAF36091-203E-4C10-AA53-7D9087114D35@unicell.co.il>
	<0207A022-1ABB-4CCA-B483-869756C47D0B@unicell.co.il>

On 2011-08-23, Herouth Maoz <herouth@unicell.co.il> 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




view thread (11+ messages)  latest in thread

Message-ID: <j2vvie$u2i$2@reversiblemaps.ath.cx>
Permalink:  ../j2vvie$u2i$2@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/j2vvie$u2i$2@reversiblemaps.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasen@xnet.co.nz
  Subject: Re: exclusion constraint for ranges of IP
  In-Reply-To: <j2vvie$u2i$2@reversiblemaps.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox