Re: How do FKs work?

From: Janning Vygen <vygen(at)gmx(dot)de>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How do FKs work?
Date: 2004-10-11 11:03:37
Message-ID: 200410111303.37986.vygen@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Am Sonntag, 10. Oktober 2004 15:01 schrieb Marc G. Fournier:
> On Sun, 10 Oct 2004, Janning Vygen wrote:
> > Am Sonntag, 10. Oktober 2004 02:43 schrieb Marc G. Fournier:
> >> On Sat, 9 Oct 2004, Tom Lane wrote:
> >>> "Marc G. Fournier" <scrappy(at)hub(dot)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 ...

Could you please show me your schema design regarding those two tables. I had
this problem too and it just lacks from an index on the foreign key.

janning

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Theo Galanakis 2004-10-11 23:23:41 Re: Export tab delimited from mysql to postgres.
Previous Message Gary Stainburn 2004-10-11 09:49:24 table update using result from join