Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C3FD71FC9B66 for ; Mon, 13 Feb 2012 13:30:56 -0400 (AST) Received: from [76.14.161.106] (helo=newserver.jfcomputer.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rwzjs-0005J9-Iw for pgsql-sql@postgresql.org; Mon, 13 Feb 2012 17:30:56 +0000 Received: from localhost (unknown [127.0.0.1]) by newserver.jfcomputer.com (Postfix) with ESMTP id CD16012346 for ; Mon, 13 Feb 2012 17:30:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at site Received: from newserver.jfcomputer.com ([127.0.0.1]) by localhost (linux-jfp8.site [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BY39hifEH0-P for ; Mon, 13 Feb 2012 09:30:39 -0800 (PST) Received: from linux-12.localnet (unknown [192.168.1.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johnf@jfcomputer.com) by newserver.jfcomputer.com (Postfix) with ESMTPSA id F1C22568E for ; Mon, 13 Feb 2012 09:30:38 -0800 (PST) From: John Fabiani To: pgsql-sql@postgresql.org Subject: Re: foreign key is it a real key Date: Mon, 13 Feb 2012 09:30:38 -0800 Message-ID: <3472508.Mrru7oBg8v@linux-12> User-Agent: KMail/4.7.2 (Linux/3.1.9-1.4-desktop; KDE/4.7.2; x86_64; ; ) In-Reply-To: <20120213155047.GA25335@tux> References: <5075215.HTHcEtzjPG@linux-12> <20120213155047.GA25335@tux> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Host-Lookup-Failed: Reverse DNS lookup failed for 76.14.161.106 (failed) X-Pg-Spam-Score: 0.8 (/) X-Archive-Number: 201202/43 X-Sequence-Number: 36336 On Monday, February 13, 2012 04:50:47 PM Andreas Kretschmer wrote: > John Fabiani wrote: > > Hi, > > I have read a few articles and I'm not sure if it's me or the authors > > but I do not believe my question was answered. > > > > If I have table that has a PK and a FK - will the planner use the FK > > just same as it would use the PK? IOW's is a FK also an index used by > > the planner? > > > > I have a lagacy table that contains a FK constraint (vendor_id --> > > vendor_info). I believe I need an index to improve the performance of a > > query because I'm using the column as part of my join. Explain does > > not appear to use it as an index (instead of a seq scan it uses a hash > > join). But the table all ready has a FK key contraint on the column. > > Yes, for large tables you have to create a own index on your fk-column. > > > Andreas Thanks Johnf