Resumable online index rebuild is one of the very useful feature of SQL Server 2017 for DBA’s. Now it is possible to pause an Index Rebuild. It allows to resume an online index rebuild operation from where it is stopped or paused. Below are some scenarios where you may need to pause your index rebuild operation.

  • If your index rebuild fails due database failure or after running out of disk space. Now you need not required to start the index rebuild from the beginning.
  • You wish to pause an index rebuild due to some other important task where you need more system resources.

Resumable online index rebuild does not require significant log space, which allows you to perform log truncation while the resumable rebuild operation is running. As far as performance is concerned there is not much difference between resumable and non-resumable online index rebuild. There is no difference in defragmentation quality as well.

Now let us see how it works.

As the name suggest you can resume an index if you rebuild using online option only. You cannot do it offline.

Resumable index - 1

Now let’s rebuild the index with resumable option ON.

While index rebuild operation is running, open a new query window and pause the index operation using below command.

When you pause an index rebuild operation SQL Server will throw below error.

Resumable index - 2

It means it kills the session under which the index rebuild was running.  So in your maintenance plan if you wanted to use resumable online index rebuild and if you pause an index rebuild then it will kill the maintenance job. This is something I was expecting that when you pause it should pause only that index rebuild for that specific index and will move to the next step of maintenance job but it doesn’t so Make sure to run your maintenance plan again.

sys.index_resumable_operations is a system view that monitors and checks the current execution status for resumable Index rebuild. Let see what is status of our index rebuild operation. As I have only one table in my database I am not using any filter in my query.

Resumable index - 3

You can see 56.42 percent of index rebuild is complete and it is in pause state.

Suppose after pausing the index you decided that we no longer required that index or table. When your index is at paused state and you wanted to drop the index or  table. SQL Server will not allow you to drop the object.

Resumable index - 4

Resumable index - 5

So when you need not required the index, it is not advisable to resume the index, rather SQL server provides you an option to abort the paused index rebuild operation. Once you abort you can able to drop the index.

Now let’s resume the index rebuild.

If you try to run a fresh rebuild, SQL Server will throw a warning message.

Warning: An existing resumable operation with the same options was identified for the same index on ‘IndexDemo’. The existing operation will be resumed instead.

Once the rebuild is over you will not find any entry in the sys.index_resumable_operations for this index.

Resumable index - 6

This is very useful for indexes on big tables which take more time to rebuild.