I have an MDF file that was autogrown from 1MB to 40GB in 10% increment. The file is heavily fragmented now, and I want to defrag it with minimum downtime.
I have a plan that I am not sure will work:
- Normally defrag the partition while the service is still running until the only fragmented files are the database files.
- Enter single user mode.
- Make complete backup to a different partition.
- Delete the database with fragmented MDF file.
- Create/restore new database from the recently created backup.
Will dropping database and then restore from backup remove the file fragmentation?
Or should I just turn off the service and run defrag tool until it finishes?