FOREIGN KEY AND INDEXEX

Lists: pgsql-novice
From: "JORGE MALDONADO" <jorgemal1960(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: FOREIGN KEY AND INDEXEX
Date: 2008-10-28 20:04:17
Message-ID: f03943a00810281304r3e6340a8qa1669047d87d1640@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I need to define an index for a table but such an index already exists as a
foreign key.
I have fk_state (a foreign key) and I need a common index (ix_state).
Should I define the index or does the foreign key work like an index too?

With respect,
Jorge Maldonado


From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: FOREIGN KEY AND INDEXEX
Date: 2008-10-28 21:26:43
Message-ID: 200810281426.43844@hal.medialogik.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Tuesday 28 October 2008, "JORGE MALDONADO" <jorgemal1960(at)gmail(dot)com>
wrote:
> I need to define an index for a table but such an index already exists as
> a foreign key.
> I have fk_state (a foreign key) and I need a common index (ix_state).
> Should I define the index or does the foreign key work like an index too?

You need the index. Primary keys and unique constraints are implemented as
indexes, but not foreign keys.

--
Alan