Re: Compound keys and foreign constraints

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: <wespvp(at)syntegra(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Compound keys and foreign constraints
Date: 2004-04-01 22:19:14
Message-ID: 3n4p60l7rshbglgfa3rvkltqml5p74d9n3@email.aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 01 Apr 2004 10:53:40 -0600, <wespvp(at)syntegra(dot)com> wrote:
>db=> explain select

EXPLAIN ANALYSE please ...

>ERROR: there is no unique constraint matching given keys for referenced
>table "messages"

>It should be able to use the new compound index, as message_key is the top
>index key.

Don't confuse the *concept* of unique constraints with the
*implementation detail* of unique btree indices. Per SQL standard you
need a unique constraint on the target column to make sure that only one
row matches any referencing value.

The target column being a part of a non-unique index (or even a unique
index) is not sufficient.

Servus
Manfred

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message wespvp 2004-04-01 22:45:23 Re: Compound keys and foreign constraints
Previous Message Marc Durham 2004-04-01 21:21:15 Re: row-level security model