Re: exclusion constraint for ranges of IP

From: Herouth Maoz <herouth(at)unicell(dot)co(dot)il>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: exclusion constraint for ranges of IP
Date: 2011-08-23 11:39:59
Message-ID: 821FD4E6-0ACA-479F-81C6-09EA6298FD16@unicell.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On 23/08/2011, at 13:31, Jasen Betts wrote:

> On 2011-08-23, Herouth Maoz <herouth(at)unicell(dot)co(dot)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.

This is an interesting concept. It's a different angle on the same condition.

>
> There seems to be no way to create this in the create-table
> command. (using 8.4 here)

Yes, it's curious that exclude constraints are the only ones which are allowed to be partial in a table definition.

Thank you.

Herouth

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Julien Cigar 2011-08-23 14:39:41 Re: WITH RECURSIVE question
Previous Message Jasen Betts 2011-08-23 10:31:42 Re: exclusion constraint for ranges of IP