Snake draft sorting in SQL Server, part 1


 

I recently had a restore job where I needed to split the work up into multiple parallel processes (which I’ll refer to here as “threads”). I wanted to balance the work so that the duration was something significantly less than the sum of the restore times.

Imagine a job that loops through and restores each database in sequence (let’s start with just four):

The restores are not finished (allowing the next step(s) to start) until the sum of the restore times for all four databases.

Instead of one job, imagine four jobs that all start at roughly the same