Re: Foreign keys

From: Jeremy Semeiks <jrs(at)farviolet(dot)com>
To: Steve Tucknott <steve(at)retsol(dot)co(dot)uk>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Foreign keys
Date: 2004-08-27 19:02:37
Message-ID: 20040827190237.GY29207@farviolet.farviolet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Aug 27, 2004 at 09:31:51AM +0100, Steve Tucknott wrote:
> PostGreSql 7.4.3
>
> Am I right in assuming that a foreign key on a table does not explicity
> create an index on that column on the foreign table? I can see via the
> \d on the table that the foreign key exists, but accessing the table on
> that column seems to use a sequential scan.

Adding the foreign key won't add the index itself, but I believe that
foreign keys can only be declared on columns declared unique.
Since declaring columns unique implicitly creates an index on them, if
you can legally declare the foreign key then "\d" should show that
the foreign key's index already exists.

It sounds like sequential scan is being used for a completely
unrelated reason.

- Jeremy

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-08-27 19:13:21 Re: Foreign keys
Previous Message Doug Silver 2004-08-27 18:12:18 Tracking down "idle in transaction" processes