From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "Marc Compte" <mcompte(at)sigte(dot)udg(dot)es> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Foreign keys and indexes |
Date: | 2007-06-05 13:35:32 |
Message-ID: | 87hcpmcymz.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Marc Compte" <mcompte(at)sigte(dot)udg(dot)es> writes:
> Does PostgreSQL create an implicit index also for foreign keys? or must I
> create it explicitly?
It won't allow you to create a foreign key that points to a column without a
unique index on it.
postgres=# create table b (i integer references a(i));
ERROR: there is no unique constraint matching given keys for referenced table "a"
However if you ever update or delete the referenced records then it also helps
performance to have an index on the referencing column which Postgres doesn't
enforce.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Bhavana.Rakesh | 2007-06-05 13:35:46 | Re: jdbc pg_hba.conf error |
Previous Message | Ron Johnson | 2007-06-05 13:33:44 | Re: Database design wisdom needed |