Complete defragmentation of an Index

  • One of my database table's index fragmentation is 86% and I am trying to rebuild the index, so that it could be defrag. But after running REBUILD WITH(FILLFACTOR=80) using ALTER INDEX, its fragmentation is still upto 70%. Same case is for some other indexes also.

    Please tell me the solution to completely defrag an index.

  • Alter index ... Rebuild is how you remove fragmentation.

    Let me guess, it's a tiny index, probably under 10 pages in size?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • yes...Page count for this index is 5

  • Way too small to care about. The generally recommended rough guide to the size of index you need to worry about for rebuilding indexes is 1000 pages.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • That's mean I need to check both avg_fragmentation_in_percent and page_count in records returned by sys.dm_db_index_physical_stats().

  • Yup. Or you can get a nice pre-written script that already does all of that, like the one at http://sqlfool.com/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply