pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Fabiani <johnf@jfcomputer.com>
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> (raw)
In-Reply-To: <20120213155047.GA25335@tux>
References: <5075215.HTHcEtzjPG@linux-12>
	<20120213155047.GA25335@tux>

On Monday, February 13, 2012 04:50:47 PM Andreas Kretschmer wrote:
> John Fabiani <johnf@jfcomputer.com> 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



view thread (3+ messages)

Message-ID: <3472508.Mrru7oBg8v@linux-12>
Permalink:  ../3472508.Mrru7oBg8v@linux-12/
Also on:    postgresql.org/message-id/3472508.Mrru7oBg8v@linux-12

 · 

reply

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: johnf@jfcomputer.com
  Subject: Re: foreign key is it a real key
  In-Reply-To: <3472508.Mrru7oBg8v@linux-12>

* 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