pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: mailreg@numerixtechnology.de
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Join Table
Date: Mon, 01 Nov 2004 17:08:51 +0000
Message-ID: <41866DA3.3020704@archonet.com> (raw)
In-Reply-To: <41866598.5040909@numerixtechnology.de>
References: <41866598.5040909@numerixtechnology.de>

T E Schmitz wrote:
> Hello,
> 
> I have created the following join table: the two FKs are the PK of the 
> table. Typically, I will need to select rows for a given ITEM_FK.
> 
> Question: is it necessary/advisable to create an index for the ITEM_FK 
> column? Or is this redundantbecause this column is already one of the PK 
> columns?
> 
> CREATE TABLE SUPPLY
> (
> ITEM_FK integer NOT NULL,
> CONTACT_FK integer NOT NULL,
> COST numeric (7,2),
> PRIMARY KEY (ITEM_FK,CONTACT_FK)
> );

The primary-key index can be used for ITEM_FK but not CONTACT_FK, so you 
might want an index on that column.

-- 
   Richard Huxton
   Archonet Ltd



view thread (7+ messages)  latest in thread

Message-ID: <41866DA3.3020704@archonet.com>
Permalink:  ../41866DA3.3020704@archonet.com/
Also on:    postgresql.org/message-id/41866DA3.3020704@archonet.com

 · 

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: dev@archonet.com, mailreg@numerixtechnology.de
  Subject: Re: Join Table
  In-Reply-To: <41866DA3.3020704@archonet.com>

* 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