SQL Server Database Table Fragmentation


How do you minimize the amount of fragmentation on your database tables that are heavily used?

I have an online SQL Server 2008 (SP2)supported application, the database has two tables that shows heavy reads/write and delete. Due to the read/write and deletes, the columns becomes easily fragemented.  However, I tend to rebuild the indexes very often, but the more I rebuild the more fragmented the indexes.  So, can somebody tell exactly what I needed to do if possible to minimize the level of fragmentation on these tables?
FavorableAsked:
Who is Participating?
 
TempDBACommented:
fillfactor is something you can consider here. If the table is updated,deleted frequently , it is good you keep the fillfactor to 50 while creating index.
0
 
FavorableAuthor Commented:
Can you show me the steps?
0
 
TempDBACommented:
its easy. just while rebuilding your index include the option.

alter index <indexname> on <tablename>
rebuild with (online = on,maxdop = 0, fillfactor = 50)

Online option will let you rebuild your index online without Locking the full table so that there is basically no downtime.
Maxdop allows you to set the degree of parallelism you want to use for rebuilding the index.
fillfactor will be used while feeling up the index page. 50 means half of the page will be filled and half will be left empty for transactions.
0
 
FavorableAuthor Commented:
accepted
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.