SQL Server – Best Way to Move Large Number of Indexes to New File-Group

sql serversql server 2014

I have requirement to move all the indexes into different storage space (file-group) within existing SQL Server 2014 Database (Current Size: ~700GB)

I'm planning for approach where i can drop existing indexes and recreate them on new file-group. I prepared a script to do the same activity (re-creating indexes one by one) with cursor, but after executing the script, my database is very slow, and it's running for more than 20 hours.

Any advise/recommendations to accomplish this activity in production database where it's got to manage more than 1,000 users requests.

Best Answer

The answer is: you cannot run heavy scripts and not slow down the DB server.

I quess all you have to do is to pick kind of light-workload-hours and REBUILD indexes one by one with your own hands monitoring blocking and overall server load.

General advice would be to use

ALTER INDEX <IndexName> REBUILD;

instead of recreating them.

Also consider ALTER INDEX options here such as:

  • ONLINE
  • RESUMABLE
  • MAX_DURATION
  • MAXDOP
  • WAIT_AT_LOW_PRIORITY

Have a look at these useful links:

Take care about free space when rebuilding online, as stated here.