I need to rebuild some big indexes and I'm doing some tests with the various options (sort_in_tempdb, maxdop, online) of the ALTER INDEX statement on an test index with 4 levels and 800000 pages on leaf level.
I noticed when I'm running the statement with Online=on the intermediate pages (level 1) of my index are higher fragmented as before (89% in stead of 3%).

The intermediate pages only get defragmented when I'm setting MAXDOP=1. With the options SORT_IN_TEMBP=ON,ONLINE=OFF the level 2 fragmentation jumps from 0 to 100.

This are the statements that caused an increase of fragmentation on level 1:

ALTER INDEX pk_test ON dbo.test REBUILD WITH (sort_in_tempdb=off,online=on,maxdop=1)
ALTER INDEX pk_test ON dbo.test REBUILD WITH (sort_in_tempdb=off,online=on)
ALTER INDEX pk_test ON dbo.test REBUILD WITH (sort_in_tempdb=on,online=on)

This statement caused the fragmentation on level 2 go from 0 to 100 but level 1 stays the same:

ALTER INDEX pk_test ON dbo.test REBUILD WITH (sort_in_tempdb=on,online=off)

Is fragmentation on intermediate pages something to worry about and what is causing the increase in fragmentation?

  • 1
    Could you post the exact ALTER INDEX... you are running? There are cases when rebuilding an index ONLINE=ON can result in higher fragmentation. – hot2use Mar 15 '18 at 15:08
  • @hot2use: I updated the question with the statements – Frederik Vanderhaegen Mar 15 '18 at 15:16
  • How many pages in level 1 / level 2? Is this fragmentation actually causing any performance issues? How did you correlate any performance issues with the fragmentation? – Aaron Bertrand Mar 20 '18 at 14:30
  • @AaronBertrand: I did not have any performance issues in this test. On level 1 I have 1500 pages and level 2 has only 2 pages. I was wondering if this could cause performance issues on a production db – Frederik Vanderhaegen Mar 22 '18 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.