10

I'm having trouble finding a definitive resource on this anywhere, so hopefully a guru can give me an answer here.

I have a very large table that we had to add a column to. The clustered index is pretty highly fragmented, and I want to do an ALTER INDEX REBUILD to clean it up.

I also normally do an ALTER TABLE REBUILD when I change the columns since this cleans up any pointers or splits from that operation.

Do I need to do both since we are talking about a the clustered index, which is essentially the table?

My suspicion is the ALTER INDEX REBUILD on the clustered will not update everything that the ALTER TABLE will, but I also am afraid that the ALTER TABLE won't clean up the index fragmentation.

JNK
  • 18,064
  • 6
  • 63
  • 98

2 Answers2

7

If you rebuild the clustered index there shouldn't be any need to rebuild the table. If the table was a heap (didn't have a clustered index) then you might want to rebuild it.

mrdenny
  • 27,106
  • 2
  • 44
  • 81
0

Rebuild drops and recreates the index. When you create a clustered index, it reorders the rows of a table in addition to creating the CIX (a table with no CIX is a heap).

Eric Higgins
  • 2,689
  • 1
  • 19
  • 25