Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
chetanb3
Yak Posting Veteran
52 Posts |
Posted - 2010-04-23 : 06:56:37
|
| Hi,I have a primary key with 4 columns included, 3 columns are uniqueidentifier and one is intDoes this will affect the performance ..? |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
|
|
chetanb3
Yak Posting Veteran
52 Posts |
Posted - 2010-05-06 : 05:43:53
|
| Thank it helps me. |
 |
|
|
DBA in the making
Aged Yak Warrior
638 Posts |
Posted - 2010-05-06 : 06:43:40
|
I try to avoid having composite primary keys unless it's absolutely necessary, or there's an obvious advantage in doing so (such as creating many-many relationships). I once worked on a DB in which many of the tables had 2, 3, 4 (even 7) columns in their primary key. It performed quite poorly, because many of the queries that joined several tables together looked like this:SELECT [columns]FROM table1 aINNER JOIN table2 b ON a.col1 = b.col1 AND a.col2 = b.col2 AND a.col3 = b.col3 AND a.col4 = b.col4INNER JOIN table2 c ON a.col1 = c.col1 AND a.col2 = c.col2 AND a.col3 = c.col3 AND a.col4 = c.col4 AND a.col5 = c.col5 So, as I was importing this data into an MIS reporting database, and once imported it didn't need to reference the original data, I decided to re-key the entire database during the import process. The performance increase was huge.------------------------------------------------------------------------------------Any and all code contained within this post comes with a 100% money back guarantee. |
 |
|
|
|
|
|