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 2B4A432AA56 for ; Sun, 10 Oct 2004 01:44:05 +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 98425-01 for ; Sun, 10 Oct 2004 00:43:57 +0000 (GMT) Received: from hub.org (hub.org [200.46.204.220]) by svr1.postgresql.org (Postfix) with ESMTP id B1AB432AA31 for ; Sun, 10 Oct 2004 01:44:00 +0100 (BST) Received: from localhost (unknown [200.46.204.144]) by hub.org (Postfix) with ESMTP id A4B2570D1D5 for ; Sat, 9 Oct 2004 21:43:56 -0300 (ADT) Received: from hub.org ([200.46.204.220]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94844-09; Sun, 10 Oct 2004 00:43:46 +0000 (GMT) Received: from ganymede.hub.org (blk-222-46-91.eastlink.ca [24.222.46.91]) by hub.org (Postfix) with ESMTP id 4C14370CC94; Sat, 9 Oct 2004 21:43:46 -0300 (ADT) Received: by ganymede.hub.org (Postfix, from userid 1000) id 562573F159; Sat, 9 Oct 2004 21:43:50 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 523B53F0DE; Sat, 9 Oct 2004 21:43:50 -0300 (ADT) Date: Sat, 9 Oct 2004 21:43:50 -0300 (ADT) From: "Marc G. Fournier" X-X-Sender: scrappy@ganymede.hub.org To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: How do FKs work? In-Reply-To: <6093.1097367833@sss.pgh.pa.us> Message-ID: <20041009214318.V54093@ganymede.hub.org> References: <20041009145332.D54093@ganymede.hub.org> <6093.1097367833@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org 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/64 X-Sequence-Number: 19167 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 ... ---- Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664