Re: Foreign keys - Mailing list pgsql-novice

From Jeremy Semeiks
Subject Re: Foreign keys
Date
Msg-id 20040827190237.GY29207@farviolet.farviolet.com
Whole thread Raw
In response to Foreign keys  (Steve Tucknott <steve@retsol.co.uk>)
Responses Re: Foreign keys
List 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

pgsql-novice by date:

Previous
From: Doug Silver
Date:
Subject: Tracking down "idle in transaction" processes
Next
From: Bruno Wolff III
Date:
Subject: Re: Foreign keys