Re: make a unique index for foreign keys? - Mailing list pgsql-sql

From Christopher Kings-Lynne
Subject Re: make a unique index for foreign keys?
Date
Msg-id GNELIHDDFBOCMGBFGEFOCELJCCAA.chriskl@familyhealth.com.au
Whole thread Raw
In response to Re: make a unique index for foreign keys?  ("Beth Gatewood" <beth@vizxlabs.com>)
Responses Re: make a unique index for foreign keys?
List 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



pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Case insensitive select
Next
From: "isaac flemmin"
Date:
Subject: Re: Case insensitive select