Re: How do FKs work?

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

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 ...
>
> Why dont you try EXPLAIN DELETE ... (without ANALYZE). it shows you the plan
> without executing it and shows you which index is missing.

Thought about that too ... shows the index being used on the thable where
the delete is happening, but doesn't show anything as concerns the FKs
themselves ...

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message sreejith s 2004-10-10 14:19:57 SQL doubt - Date Add
Previous Message Janning Vygen 2004-10-10 12:24:32 Re: How do FKs work?