Re: setting up foreign keys - Mailing list pgsql-performance

From Chris
Subject Re: setting up foreign keys
Date
Msg-id 44DAEB04.9050306@gmail.com
Whole thread Raw
In response to setting up foreign keys  (Sue Fitt <sue@inf.ed.ac.uk>)
Responses Re: setting up foreign keys  (Sue Fitt <sue@inf.ed.ac.uk>)
List pgsql-performance
Sue Fitt wrote:
> Hi all,
>
> This is my first post to the performance list, I hope someone can help me.
>
> I'm setting up a table with 2 columns, both of which reference a column
> in another table:
>
> CREATE TABLE headwords_core_lexemes (
> core_id int REFERENCES headwords_core(core_id),
> lexeme_id int REFERENCES headwords_core(core_id),
> );

One problem here is both of these are referencing the same column ;) I'm
sure that's a typo.

It sounds like you have something blocking or locking the other table.
Check pg_locks (I think it is), 13,000 rows shouldn't take *that* long.


Make sure there is an index on headwords_core(core_id) and whatever the
other column should be.

Foreign keys have to check the other table so without those indexes, it
will be slow(er).

--
Postgresql & php tutorials
http://www.designmagick.com/

pgsql-performance by date:

Previous
From: Sue Fitt
Date:
Subject: setting up foreign keys
Next
From: Sue Fitt
Date:
Subject: Re: setting up foreign keys