Hi SQL Server Gurus,
So I have successfully moved the primary files across to a new drive.
In my work today I did come across the idea of using the restore move command.
I am not an SQL server DBA and so I did not know about the restore move command.
I have put an example below.
The DWH database I am moving is 4+TB and goes back to 2008. We have 2000+ files that make up the database. With that massive number of files you can see why I have taken the approach of creating new files across drives and doing a shrinkfile with empty commands.
(SQL Server will tell me if I make a mistake and it will not corrupt or damage the database. It also keeps the database up. The customer has 450 stores nationwide and inventory being delivered needs to make it into the DWH on an hourly basis. So a multi-hour down time is not really acceptable even on weekends.)
However, when I moved one of the smaller databases I noticed that I could generate a script as follows that allows me to move files from the backup file to a target. I did not know about this.
So...my question is this. If I had tried something like this on a 4TB, 2000+ file data warehouse, how would it manage the indexes?
When indexes are in the same file as the data they index then SQL Server updates the relative address of the data in the index as it restores the file. But keeping indexes in different files to tables has overwhelming advantages in a data warehouse. And this is where much of the time goes in moving data. When you use Shrinkfile SQL Server updates the indexes as it moves the rows. If the index and the data are in the same file this happens quickly. If the indexes are in a different file this happens slowly.
So I can't see how a restore would restore a table in one file and an index for the table in another file "quickly". My thinking is that a restore database like this would "run forever". But since I really don't want to test it myself on a 4TB+ data warehouse I was wondering if anyone knows the behaviour of the restore command when you move files and the table data is in separate files to the index data. The indexes have to be updated to point to the new disk and the new file and my guess is that such a restore would take "forever".
But I might be wrong.
Have any of you SQL Server DBAs done this before? If so? May I please ask you to be so kind as to share your observations here?
Thank you for any assistance you may be able to offer on this matter. I really appreciate it.
Best Regards
Peter
RESTORE DATABASE [YourDB] FROM DISK = N'D:\SQL_Backup\YourDB.bak' WITH FILE = 1,
MOVE N'YourDB' TO N'L:\SQL_Data\YourDB\YourDB_01.mdf',
MOVE N'FG_YourDB_PROD_01' TO N'L:\SQL_Data\YourDB\P_FG_YourDB_PROD_01.ndf',
MOVE N'YourDB_log' TO N'L:\SQL_Log\YourDB\YourDB_log.ldf',
NOUNLOAD, STATS = 5