Re: Foreign keys and slow insert

From: Richard Huxton <dev(at)archonet(dot)com>
To: Dan Black <fireworker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Foreign keys and slow insert
Date: 2005-06-08 16:15:30
Message-ID: 42A719A2.2060804@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dan Black wrote:
> I read in documentation that primary key doesn't require additional indexes
> but I could find nothing about foreign keys.
> Do I need to create additional indexes when I create foreign keys?
> Example:
> create table master

> create table slave

> Do I need to create index
>
> CREATE INDEX my_index
> ON slave
> USING btree
> (master_id);

Yes. The primary key uses a "UNIQUE INDEX" to enforce uniqueness, so you
get the index for "free". The foreign-key has no such constraint of course.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2005-06-08 16:16:40 Re: Foreign keys and slow insert
Previous Message Richard Huxton 2005-06-08 16:11:59 Re: Bug with view definition?