10

In SQL Server 2005, the query analyzer has told me many times to create a non-clustered index on a primary ID column of a table which already has a clustered index. After following this recommendation, the query execution plan reports that the query should be faster.

Why would a Non-Clustered index on the same column (with the same sort order) be faster than a Clustered index?

Yuck
  • 49,664
  • 13
  • 105
  • 135
Kevin Berridge
  • 6,251
  • 6
  • 41
  • 42

3 Answers3

16

A clustered index has all the data for the table while a non clustered index only has the column + the location of the clustered index or the row if it is on a heap (a table without a clustered index). So if you do a count(column) and that column is indexed with a non clustered index SQL server only has to scan the non clustered index which is faster than the clustered index because more will fit on 8K pages

SQLMenace
  • 132,095
  • 25
  • 206
  • 225
2

I'd guess it would be faster in cases where you don't need the full row data, for example if you're just checking if a row with a given ID does exist. Then a clustered index would be rather huge while a small "one column" index would be much slimmer.

BlaM
  • 28,465
  • 32
  • 91
  • 105
-1

A clustered index will generally be faster, but you can only have 1 clustered index. So if the table already has a clustered index on a different column, then a non-clustered index is the best you can do.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794