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 247F43A462A for ; Mon, 1 Nov 2004 17:07:47 +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 92115-06 for ; Mon, 1 Nov 2004 17:07:45 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 57F433A4609 for ; Mon, 1 Nov 2004 17:07:44 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iA1H7cbD014977; Mon, 1 Nov 2004 12:07:39 -0500 (EST) To: mailreg@numerixtechnology.de Cc: pgsql-sql Subject: Re: Join Table In-reply-to: <41866598.5040909@numerixtechnology.de> References: <41866598.5040909@numerixtechnology.de> Comments: In-reply-to T E Schmitz message dated "Mon, 01 Nov 2004 16:34:32 +0000" Date: Mon, 01 Nov 2004 12:07:38 -0500 Message-ID: <14976.1099328858@sss.pgh.pa.us> From: Tom Lane 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: 200411/9 X-Sequence-Number: 19328 T E Schmitz writes: > CREATE TABLE SUPPLY > ( > ITEM_FK integer NOT NULL, > CONTACT_FK integer NOT NULL, > COST numeric (7,2), > PRIMARY KEY (ITEM_FK,CONTACT_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? The PK index will be usable for searches on ITEM_FK alone (though *not* for searches on CONTACT_FK alone --- a moment's thought about the index sort order should convince you why). It would be marginally less efficient for this purpose than a dedicated index on ITEM_FK. But unless your use of this table is almost all searches and hardly any modifications, adding a dedicated index is probably a net loss due to the added update costs. regards, tom lane