sql server - Is there any advantage in creating a clustered index - if we are not going to query/search for records based on that column? -


i doing review of db tables created in our project , came across this. table contains identity column (id) primarykey table , clustered index has been defined using id column. when @ sproc retrieves records table, see id column never used in query , query records based on userid column (this column not unique) , there can multiple records same userid.

so question there advantage/purpose in creating clustered index when know records wont queried column?

if identity column never used in where , join clauses, or referenced foreign keys, perhaps userid should clustered primary key. question need id column @ in case.

the best choice clustered index depends on how table queried. if majority of queries userid, should unique clustered index (or clustered unique constraint) , id column non-clustered.

keep in mind clustered index key implicitly included in non-clustered indexes row locator. implication non-clustered indexes may more cover queries , non-clustered index leaf node pages wider result.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -