Creating a foreign key - Mailing list pgsql-performance

From Campbell, Lance
Subject Creating a foreign key
Date
Msg-id B10E6810AC2A2F4EA7550D072CDE8760CDDD46@SAB-FENWICK.sab.uiuc.edu
Whole thread Raw
Responses Re: Creating a foreign key  ("Joshua D. Drake" <jd@commandprompt.com>)
Re: Creating a foreign key  (Shaun Thomas <sthomas@leapfrogonline.com>)
Re: Creating a foreign key  (PFC <lists@peufeu.com>)
List 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

 

pgsql-performance by date:

Previous
From: Justin
Date:
Subject: Re: [GENERAL] Ubuntu question
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Creating a foreign key