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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Primary Key with 4 colums -Performance Issue?

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 int

Does this will affect the performance ..?


GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-04-23 : 08:07:43
Depends. Is the primary key enforced by a clustered index (the default) or a nonclustered index?

If it's the clustered index, this may be of use: http://www.sqlservercentral.com/articles/Indexing/68563/

--
Gail Shaw
SQL Server MVP
Go to Top of Page

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2010-05-06 : 05:43:53
Thank it helps me.
Go to Top of Page

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 a
INNER JOIN table2 b
ON a.col1 = b.col1
AND a.col2 = b.col2
AND a.col3 = b.col3
AND a.col4 = b.col4
INNER 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.
Go to Top of Page
   

- Advertisement -