Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Oliver Elphick
On Tue, 2007-06-05 at 17:07 +0200, Marc Compte wrote: > > For instance, in the implementation of a N:M relationship, declaring > the > primary as (foreign1, foreign2) will create two indexes? or just one? Just one -- Oliver Elphick [EMAIL PROTECTED] Isl

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Scott Marlowe
Marc Compte wrote: Thanks to everyone for the prompt reply :) Good thing about answers is when they raise up new questiosn, so you can keep on learning all the time. This one answer, for instance, brings me another question. Does having a composite primary mean the system will create an indi

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Marc Compte
Thanks to everyone for the prompt reply :) Good thing about answers is when they raise up new questiosn, so you can keep on learning all the time. This one answer, for instance, brings me another question. Does having a composite primary mean the system will create an individual index on eac

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Gregory Stark
"Marc Compte" <[EMAIL PROTECTED]> 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)); E

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread A. Kretschmer
am Tue, dem 05.06.2007, um 11:49:20 +0200 mailte Marc Compte folgendes: > Dear list, > > This might be too basic for a question but I just couldn't find the > answer so far. > > Does PostgreSQL create an implicit index also for foreign keys? No, only for primary keys to enforce the uniqueness.

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Richard Broersma Jr
> Does PostgreSQL create an implicit index also for foreign keys? or must > I create it explicitly? No, you foreign keys are not automatically indexed. They only way they would be is if the FK is part of a composite unique or primary key. So you will probably have to create your one indexes o

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Michael Fuhr
On Tue, Jun 05, 2007 at 11:49:20AM +0200, Marc Compte wrote: > Does PostgreSQL create an implicit index also for foreign keys? or must > I create it explicitly? PostgreSQL doesn't create an index on the referencing column(s) of a foreign key constraint; if you want an index then you'll need to cr

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Ragnar
On þri, 2007-06-05 at 11:49 +0200, Marc Compte wrote: > Does PostgreSQL create an implicit index also for foreign keys? no > or must I create it explicitly? if you want one, yes. not everyone wants an index on all their foreign keys, but they can be useful in some circumstances. gnari --

Re: [GENERAL] Foreign keys and indexes

2007-06-05 Thread Filip Rembiałkowski
2007/6/5, Marc Compte <[EMAIL PROTECTED]>: Dear list, This might be too basic for a question but I just couldn't find the answer so far. Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? FK is just a constraint, you wil have to create indexes manu

[GENERAL] Foreign keys and indexes

2007-06-05 Thread Marc Compte
Dear list, This might be too basic for a question but I just couldn't find the answer so far. Does PostgreSQL create an implicit index also for foreign keys? or must I create it explicitly? Thank you, Marc Compte ---(end of broadcast)--- TIP