|
Posted by gilles27 on 10/03/82 11:29
I am currently undertaking a review of the primary keys in a SQL Server
2000 database with a view to improving performance of queries.
I have heard that, in the case of compound primary keys, it is
important to select the correct order for the columns within the key.
For instance, imagine a table called OrderLine which has primary key
columns as follows-
Ledger
OrderNumber
OrderLineNumber
The theory I have heard is that columns with the most distinct values
should come first. In this case, Ledger is likely to have a maximum of
6 distinct values, OrderNumber a maximum of 10 million and OrderLine up
to 99. Based on this supposition I believe the best order would be-
OrderNumber
OrderLineNumber
Ledger
I have performed a few rudimentary tests that appear to bear this out.
I was wondering if anyone else has tried something similar and if so
what was the result?
Thanks,
Ross
Navigation:
[Reply to this message]
|