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 |
sql_server_dba
Posting Yak Master
167 Posts |
Posted - 2011-01-11 : 23:50:50
|
All,I have 20 tables with a primary key and non-clustered indexes. I am doing some performance tests and figured out that the primary keys are not used in any of the user queries. So my question is...Is it better to keep the primary key as it is or is it better to add a column to it which would be included in queries?Any suggestions would be highly appreciated. |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-01-12 : 00:59:43
|
All depends. But sounds like the PK was poorly chosen, or the queries are poorly written.BUT if the PK is the best PK for your business rules, and the queries are ok, then perhaps what you want to do is to make the PK non-clustered and then cluster on some other key (maybe make one of your non-clustered indexes).No one can say for sure without really sampling the data and reviewing the queries. But in very general terms, if your Clustered Primary Key is never used in any query plan, then something is wrong and can be improved upon.How did you determine that the PKs aren't being used? Are you querying Sys.dm_db_index_usage_stats? |
|
|
RobertKaucher
Posting Yak Master
169 Posts |
Posted - 2011-01-12 : 09:22:25
|
My primary suspect here would be poorly written queries. But that is just a guess.As russell stated you would have to look at both the data and the queries to be sure. Could you post some of the queries here for us to see?===http://www.ElementalSQL.com/ |
|
|
|
|
|