yochananrachamim / AzureSQL

129 stars 61 forks source link

Add time limit for maintenance (time limit for start of new command) #26

Open yochananrachamim opened 2 years ago

yochananrachamim commented 2 years ago

I like the idea posted in the blog post, seeking for suggestion to limit the time for the maintenance. here is the comment:

Matt Darnell Occasional Visitor ‎Jan 14 2022 07:01 PM Hi Yochanan,

This works well so thank you for the great blog. However, we find some of the databases are massive and we wanted to see if you had any suggestions to how we could add a time limit to the maintenance.. IE we only have a 100 Min window when its not being used, so we cant run full maintenance all the time, this works as it always takes the highest fragmented indexes first - then periodically we have a longer window where we can upscale the Database and run full maintenance, then down scale back to production cores.

This way we do as much maintenance in a small window as possible and we find if we do this nightly we actually do catch up with the normal fragmentation. anything that spills over gets done in the monthly longer window.

But currently, we have to interrupt the automation manually. we were hoping for some sleep and have the automation stop the query after X time.

regards Matt

there are two options, we can set time limit for starting new commands. however, is we start long running command just a second before time limit, we might go beyond the time. for resumable index operation we can just stop the command and resume after.