Why would you ever designate a primary key as non-clustered?
-
Any ideas? I'm coming across this, and it makes no sense to me. Marc
-
Any ideas? I'm coming across this, and it makes no sense to me. Marc
i wasnt aware that you could create a PK that wasnt clustered, i thought they were all clustered indexes.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
i wasnt aware that you could create a PK that wasnt clustered, i thought they were all clustered indexes.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
In SQL Server they are clustered as default. But you can make then non-clustered and use the clustered index for yourself.
--------------------------- Blogging about SQL, Technology and many other things
modified on Friday, June 20, 2008 12:20 AM
-
Any ideas? I'm coming across this, and it makes no sense to me. Marc
As I'm sure you know - it depends on your database design and how you access the tables. I think they are made this way by default to ensure at least some "workable" indexes for default databases from people who haven't looked too much into indexation. Because if you mainly access a table via - for example - foreign keys and extract 2 or 3 specific rows of data, it makes sense - to me at least :D - to make that your clustered index. Also if your PK is primarily an identity or similar number which mattes little then I would also say it makes sense to keep that index non-clustered, because it usually means you'll access data not in the index anyway and the benefits of the clustered index diminishes. However if your primary key consists of "relevant data" and you need to access this data only - and often - then it is beneficial to have it as clustered. In my opinion - it is as all things with databases, a case-by-case evaluation, but as mention first - my main guess is that it is made to simply have some "default" clustered indexes for the default databases, and those who know what they are doing will evaluate whether it is a beneficial index and change it if not anyway.
--------------------------- Blogging about SQL, Technology and many other things
-
In SQL Server they are clustered as default. But you can make then non-clustered and use the clustered index for yourself.
--------------------------- Blogging about SQL, Technology and many other things
modified on Friday, June 20, 2008 12:20 AM
makes sense...thanks, but i'm going to assume they arent doing that in the table Marc's looking at.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Any ideas? I'm coming across this, and it makes no sense to me. Marc