sql - when do you prefer to use non clustered index over clustered index? -


i've knowledge of using clustered index , non clustered index, i'm not sure when , on conditions helpful use non clustered index on clustered index. can explain or provide links helpful of us.

pick clustered index! every "regular" data table ought have clustered index, since having clustered index indeed speed lot of operations - yes, speed up, inserts , deletes! if pick good clustered index.

it's most replicated data structure in sql server database. clustering key part of each , every non-clustered index on table, too.

you should use extreme care when picking clustering key - should be:

  • narrow (4 bytes ideal)

  • unique (it's "row pointer" after all. if don't make unique sql server in background, costing couple of bytes each entry times number of rows , number of nonclustered indices have - can costly!)

  • static (never change - if possible)

  • ideally ever-increasing won't end horrible index fragmentation (a guid total opposite of clustering key - particular reason)

  • it should non-nullable , ideally fixed width - varchar(250) makes poor clustering key

anything else should second , third level of importance behind these points ....

see of kimberly tripp's (the queen of indexing) blog posts on topic - has written in blog absolutely invaluable - read it, digest - live it!


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -