X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A41E632A8BE for ; Sun, 10 Oct 2004 13:24:41 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18422-09 for ; Sun, 10 Oct 2004 12:24:35 +0000 (GMT) Received: from pw6tiger.de (pw6tiger.de [217.160.140.116]) by svr1.postgresql.org (Postfix) with SMTP id CB570329EAA for ; Sun, 10 Oct 2004 13:24:36 +0100 (BST) Received: (qmail 7870 invoked by uid 505); 10 Oct 2004 12:24:35 -0000 Received: from vygen@gmx.de by planwerk6 by uid 89 with qmail-scanner-1.14 (virus scan: Clear:. Processed in 0.289916 secs); 10 Oct 2004 12:24:35 -0000 Received: from p508cdf37.dip0.t-ipconnect.de (HELO ?192.168.1.102?) (vygen@planwerk6.de@80.140.223.55) by pw6tiger.de with SMTP; 10 Oct 2004 12:24:34 -0000 From: Janning Vygen To: "Marc G. Fournier" Subject: Re: How do FKs work? Date: Sun, 10 Oct 2004 14:24:32 +0200 User-Agent: KMail/1.7 Cc: pgsql-sql@postgresql.org References: <20041009145332.D54093@ganymede.hub.org> <6093.1097367833@sss.pgh.pa.us> <20041009214318.V54093@ganymede.hub.org> In-Reply-To: <20041009214318.V54093@ganymede.hub.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200410101424.32846.vygen@gmx.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/66 X-Sequence-Number: 19169 Am Sonntag, 10. Oktober 2004 02:43 schrieb Marc G. Fournier: > On Sat, 9 Oct 2004, Tom Lane wrote: > > "Marc G. Fournier" 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