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 2000 Forums
 SQL Server Development (2000)
 Primary Key Index vs ordinary Index

Author  Topic 

geossl
Yak Posting Veteran

85 Posts

Posted - 2004-03-31 : 23:24:19
Dear All,
There is a table user with
UserID: Integer (PK)
UserName: nvarchar

When I add an ordinary index, the execution plan will use it instead of the primary key index.

Does it mean that ordinary index is faster?

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-04-01 : 00:15:04
when a primary key is added an clustered index is created unless u specify it otherwise, i think the execution plan will use the clustered index which is created on the table be it a primary key or the other index.
what do u mean by ordinary index?

He is a fool for five minutes who asks , but who does not ask remains a fool for life!
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-04-01 : 01:58:47
As far as the execution plan is concerned there is no difference between a PK and an index.
The PK will have a unique index to support it and that is what is used for the plan.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

geossl
Yak Posting Veteran

85 Posts

Posted - 2004-04-05 : 21:11:11
I have confused the question.

The primary is composed of two fields
UserID: Integer
DeptID: Integer

When indices are created to userid and deptid, the execution plan will use those indices instead of the primary key

SELECT *
FROM tbl
WHERE UserID = 1
AND DeptID = 8
Go to Top of Page
   

- Advertisement -