Creating a foreign key

From: "Campbell, Lance" <lance(at)uiuc(dot)edu>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Creating a foreign key
Date: 2008-05-08 16:52:50
Message-ID: B10E6810AC2A2F4EA7550D072CDE8760CDDD46@SAB-FENWICK.sab.uiuc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

PostgreSQL: 8.2

When you create a foreign key to a table is there an index that is
created on the foreign key automatically?

Example:

Table A has a field called ID.

Table B has a field called fk_a_id which has a constraint of being a
foreign key to table A to field ID.

Is there an index automatically created on field fk_a_id in table B when
I create a foreign key constraint?

I assume yes. But I wanted to check. I did not see it specifically
mentioned in the documentation.

I also see "CREATE TABLE / PRIMARY KEY will create implicit index" when
creating a primary key but I don't see any similar statement when
creating a foreign key.

Thanks,

Lance Campbell

Project Manager/Software Architect

Web Services at Public Affairs

University of Illinois

217.333.0382

http://webservices.uiuc.edu

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Joshua D. Drake 2008-05-08 17:00:14 Re: Creating a foreign key
Previous Message Justin 2008-05-08 07:49:25 Re: [GENERAL] Ubuntu question