Re: make a unique index for foreign keys?

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Beth Gatewood" <beth(at)vizxlabs(dot)com>, <josh(at)agliodbs(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: make a unique index for foreign keys?
Date: 2002-06-13 01:53:12
Message-ID: GNELIHDDFBOCMGBFGEFOCELJCCAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> Thanks for the response and guidelines. I think that I figured out
> something concerning indices and foreign keys...It seems like a non-unique
> index is automatically getting created for my foreign keys. Does
> this make
> sense?

Hmm...nope. Creating a foreign key doesn't create an index. However,
creating a primary key does - sure you're not getting mixed up there?

> I got this hunch from this function I found while peeking through the
> archives today...
> pg_get_indexdef(oid); // oid should be the oid of the index you are
> investigating
>
> Using this I discovered some indices on foreign keys that I didn't
> explicitly create.

Postgres doesn't create indices for you, unless as part of a primary key or
unique constraint.

Chris

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message isaac flemmin 2002-06-13 02:06:02 Re: Case insensitive select
Previous Message Stephan Szabo 2002-06-13 01:34:05 Re: Case insensitive select