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 85CAA3A4638 for ; Mon, 1 Nov 2004 17:09:11 +0000 (GMT) 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 93800-03 for ; Mon, 1 Nov 2004 17:09:05 +0000 (GMT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 81B653A4613 for ; Mon, 1 Nov 2004 17:09:04 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) id 1COfgR-000Ctb-5s; Mon, 01 Nov 2004 17:09:33 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id CDFC4175B0; Mon, 1 Nov 2004 17:08:52 +0000 (GMT) Message-ID: <41866DA3.3020704@archonet.com> Date: Mon, 01 Nov 2004 17:08:51 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: mailreg@numerixtechnology.de Cc: pgsql-sql Subject: Re: Join Table References: <41866598.5040909@numerixtechnology.de> In-Reply-To: <41866598.5040909@numerixtechnology.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/10 X-Sequence-Number: 19329 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