Wednesday, January 1, 2014

How to fix the fragmentation on heaps?

We know that heaps are the tables without clustered index on. It may have many non clustered index (NCI) but still it is considered a heap. So consider a huge table (heap) that is fragmented. How would you fix it? Technically, you cannot defrag a heap table. But remember we have ALTER table REBUILD command which works very well on the heaps. But there is one big But. If you have many NCI on the table this command will rebuild all of them at once. What does it mean? It can produce transaction-log bloat which hits the over all performance. Think about the process the scan the log or perhaps Log Shipping job that needs to move the log file to the remote server. All this affects performance.

So, to answer the question ,we need to create a clustered index on that table..That is simple answer to the question.

I was very impressed by this post, this site has always been pleasant news. Thank you very much for such an interesting post. Keep working, great job! In my free time, I like play game: vex3game.com. What about you?

I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.Very interesting blog. www.baixarfacebookgratis.com.br

About Me

The goal of this blog is to share my knowledge as a DBA/Developer in SQL Server area. Many years ago I started to collect some tips and tricks from many experts of SQL Server around the world as well as the scripts developed by myself. And I really want to share them with you. Also my intend is to help beginners as well as experienced people such I have been doing at microsoft forums. So please do not hesitate to write me comments or questions.