Re: How do FKs work? - Mailing list pgsql-sql

From Janning Vygen
Subject Re: How do FKs work?
Date
Msg-id 200410101424.32846.vygen@gmx.de
Whole thread Raw
In response to Re: How do FKs work?  ("Marc G. Fournier" <scrappy@postgresql.org>)
Responses Re: How do FKs work?
List pgsql-sql
Am Sonntag, 10. Oktober 2004 02:43 schrieb Marc G. Fournier:
> On Sat, 9 Oct 2004, Tom Lane wrote:
> > "Marc G. Fournier" <scrappy@hub.org> writes:
> >> Have a table with two FKs on it ... 2 different fields in the table
> >> point to the same field in another table ...
> >>
> >> When I do an 'EXPLAIN ANALYZE DELETE FROM table WHERE field = #;', it
> >> never comes back ... or, at lesat, takes a *very* long time ...
> >
> > Do you have indexes on the referencing columns?  Are they exactly the
> > same datatype as the referenced column?  You can get really awful plans
> > for the FK-checking queries if not.
>
> Yup, that was my first thought ... running SELECT's joining the two tables
> on the FK fields shows indices being used, and fast times ...

Why dont you try EXPLAIN DELETE ... (without ANALYZE). it shows you the plan 
without executing it and shows you which index is missing.

janning



pgsql-sql by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: How do FKs work?
Next
From: "Marc G. Fournier"
Date:
Subject: Re: How do FKs work?