From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | mailreg(at)numerixtechnology(dot)de |
Cc: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Join Table |
Date: | 2004-11-01 17:07:38 |
Message-ID: | 14976.1099328858@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
T E Schmitz <mailreg(at)numerixtechnology(dot)de> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2004-11-01 17:08:51 | Re: Join Table |
Previous Message | Michael Fuhr | 2004-11-01 17:03:24 | Re: Join Table |