Re: [PERFORM] Creating a foreign key

2008-05-08 Thread PFC
When you create a foreign key to a table is there an index that is created on the foreign key automatically? No, Postgres doesn't do it for you, because if you create (ref_id) references table.id, you will perhaps create an index on (ref_id, date) which would then fill the purpose (and ot

Re: [PERFORM] Creating a foreign key

2008-05-08 Thread Campbell, Lance
Message- From: Shaun Thomas [mailto:[EMAIL PROTECTED] Sent: Thursday, May 08, 2008 12:19 PM To: Campbell, Lance Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Creating a foreign key On Thu, 2008-05-08 at 17:52 +0100, Campbell, Lance wrote: > Is there an index automatica

Re: [PERFORM] Creating a foreign key

2008-05-08 Thread Shaun Thomas
On Thu, 2008-05-08 at 17:52 +0100, Campbell, Lance wrote: > Is there an index automatically created on field fk_a_id in table B > when I create a foreign key constraint? No. The problem with doing this is it assumes certain things about your infrastructure that may be entirely false. Indexes a

Re: [PERFORM] Creating a foreign key

2008-05-08 Thread Joshua D. Drake
On Thu, 8 May 2008 11:52:50 -0500 "Campbell, Lance" <[EMAIL PROTECTED]> wrote: > PostgreSQL: 8.2 > > > > When you create a foreign key to a table is there an index that is > created on the foreign key automatically? No. Joshua D. Drake -- The PostgreSQL Company since 1997: http://www.comm

[PERFORM] Creating a foreign key

2008-05-08 Thread Campbell, Lance
PostgreSQL: 8.2 When you create a foreign key to a table is there an index that is created on the foreign key automatically? Example: Table A has a field called ID. Table B has a field called fk_a_id which has a constraint of being a foreign key to table A to field ID. Is there an