Each of our 10000 integration tests need to restore the database to its original "clean" state before each of them are done, during a cleanup stage. Running all tests takes time, and 80% of the time is spent during the database restore operation.
The restore operation simply takes a backup from disc and restores it.
I am now wondering if there is a way to optimize this.
One option I am thinking of is to change the location of the backup file from disc to memory. Is that possible?
Another option would be to take a snapshot of the table data only, and save only that as the backup data. I assume then that the backup file becomes smaller, and therefore faster to restore. Is that possible?
Ideally, I would like to avoid restoring, and just reset the affected data (the data that each test produces). Something like: "revert any table rows that were modified since the test started"
What options do i have? I am not an expert in this area but it feels like my problem should have an easy solution.
Best Answer
Database snapshots are probably the right answer for your specific situation, per Nic's comment.
But for future users finding this question, there are definitely ways to improve native SQL database backup and restore times: