People think that we who work with databases are boring people -I say NO, we´re…
You do your homework, check which index are fragmented and rebuild them. Thinking all is well. Then just to be sure you run the check again to see how much better it got. Surprisingly, the frag % is even bigger!
My story: I had an index with 80% fragmentation and ran a rebuild index with ALTER INDEX REBUILD. With no other access to the table as far as I know, the fragmentation % went UP to 83%. Tried again – next run got it down to 50%, not good enough. But I felt I was on to something so I ran it again. Now up to 86% etc. That happened to depend on 1) having set maxdop <>1 (it was set to 2 at the time on that SQL 2005 instance) and 2) “allow_page_locks = OFF” (actually that was an earlier mistake by a developer so we could easily change that to = ON and then it started to work again.
What SQL Server does is that it spreads out the rebuild of the index to multiple threads and each thread writes in different parts. The result is a couple of individually defragmented parts but in the whole it is still fragmented on disk. We could also have solved it by setting maxdop=1 but in this case we wanted to have multiple threads rebuilding it. Not defragging it was not an option, of course. Do you have your indecies under the microscope? If not you could contact us , not if, but when, you are starting to have performance problems.