Ed (Ed@discussions.microsoft.com) writes:
[quoted text, click to view] > If there are two tables with 1 to many relationship.
> In order to speed up the join, what would be the major different if I
> put the Clustered or Non-Clustered index on ForeignKey (Many Side) and
> MajorKey(One Side)??? If I put Clustered on both, would it be faster or
> it doesn't matter if I put Non clustered?? The reason I ask is because
> I would like to put the clustered index on a date field instead of the
> key field. since the key field join to another table, I am not sure if
> it will slow down the query if i remove the clustered and replace it
> with non clustered...
It's difficult to answer for sure given this little information. Where
to place the clustered index can often be a delicate question. But, to
take a little more concreate example, consider an Orders and an OrderDetails
table. For the OrderDetails it is typically a good idea to cluster on
the primary key (OrderID, RowNo), as you often retrieve all rows for an
order. On the other hand, Orders is likely to have a better column to
cluster on than the OrderId, for instance OrderDate or CustomerId.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at