Frederick understands this very well, and this is really what Kimberly Tripp also preaches: the clustering key must be stable (never changing), constantly increasing (IDENTITY INT), small and unique.
In your scenario, I would rather put the clustering key in the BIGINT column, and not in the VARCHAR (80) column.
First of all, with a BIGINT column it is reasonably easy to ensure uniqueness (if you do not use and guarantee uniqueness on your own, SQL Server will add a 4-byte “unique fier” for each of your rows) and it is MUCH less average than VARCHAR (80).
Why is size so important? A clustering key will also be added to EACH and each of your nonclustered indexes - so if you have many rows and many nonclustered indexes, then 40-80 bytes versus 8 bytes can quickly make a HUGE difference.
In addition, another performance tip: To avoid the so-called bookmark searches (from the value in your non-clustered index using the clustering key to the actual data pages), SQL Server 2005 introduced the concept of “including columns” in your non-clustered indexes. They are very useful and often overlooked. If your queries often require index fields, plus only one or two other fields from the database, consider including these questions to achieve what is called "index coverage." Again - see Kimberly Tripp's great article - it is SQL Server Indexing Goddess! :-) and it can explain that the material is much better than I can ...
So, to summarize: put your clustering key on a small, stable unique column - and you will do everything in order!
Mark
marc_s May 01 '09 at 20:37 2009-05-01 20:37
source share