To cluster of not
Tony's blogged about the use of heaps http://sqlblogcasts.com/blogs/tonyrogerson/archive/2007/06/24/row-fragmentation-hopscotch-heap-v-clustered-and-io-cost.aspx.
Whilst this highlights data on a page being out of sequence and thus yoyoing
when you scan the data, it doesn't mean you should always have a clustered
index.
The stats in Tony's blog are only because the query is a full table scan
in the first (heap) query. With a clustered index you are not doing a table scan
your are only doing a partial scan and so the reads are different. If you remove
the where clause thus forcing a table scan then the heap is qucker because it is
more compact, it has to read less pages.
You can also address these issues with a covering index. An non clustered
index is effectively the its own special table with a clustered index with the
leaf pages also containing the Row id or Primary key column.
Also the issue here is highlighted by a scan. If you are performing an
operation that does a seek heaps aren't bad. Also clustered indexes result in
the whole row being read, thus if you only need a few rows they can also be
worse than a heap with a covering index.
Finally having a clustered index is beneficial if you key size is < 8
bytes because the key is put in the leaf of non-clustered indexes. Whereas a
heap the row id is and the row id is 8 bytes
Finally with clustered indexes you will end up with page splits, this can
result in page fragmentation across the database file, the worst case would be
that in order to read 8 pages (8k), 8 extents(64k) would have to be read
because each page is on a different extent. The ALTER INDEX REORGANISE and
REBUILD address this fragmentation by the former moving pages to be in the
same order on disk as logically and also compacting pages in and the latter
rebuilding the index entirely. REORGANISE is an online operation.
Following this post Tony and I have had a very long discussion. The bottom
line is that if there is one thing you should learn its the internals of
indexes. This would be my starter, heaps and b trees, covering
indexes, bookmark lookups, included columns, page fragmentation, page splitting
...
-