From: Janning Vygen <vygen@gmx.de>
To: Marc G. Fournier <scrappy@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: How do FKs work?
Date: Mon, 11 Oct 2004 13:03:37 +0200
Message-ID: <200410111303.37986.vygen@gmx.de> (raw)
In-Reply-To: <20041010100007.P54093@ganymede.hub.org>
References: <20041009145332.D54093@ganymede.hub.org>
<200410101424.32846.vygen@gmx.de>
<20041010100007.P54093@ganymede.hub.org>
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@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 ...
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: vygen@gmx.de, scrappy@postgresql.org
Subject: Re: How do FKs work?
In-Reply-To: <200410111303.37986.vygen@gmx.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox