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