| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | mailreg(at)numerixtechnology(dot)de |
| Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: Join Table |
| Date: | 2004-11-01 17:08:51 |
| Message-ID: | 41866DA3.3020704@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | T E Schmitz | 2004-11-01 18:12:02 | Re: Join Table |
| Previous Message | Tom Lane | 2004-11-01 17:07:38 | Re: Join Table |