Hubba Hubba
Over in my GitHub repo, I’ve added a file that will create an Agent Job to update statistics using Ola Hallengren’s IndexOptimize script.
It’s something I hand out enough that I figured people might be interested in it. Currently, it’s not a default offering from Ola, it’s uh… custom code.
There are lots of people who should be using this, too.
- Everyone
Because index maintenance scripts don’t measure a generally useful KPI, and one of the main benefits of index rebuilds is the statistics update.
Mindful
Some thing to keep in mind here:
- You need to be using a relatively new version of Ola’s scripts
- This script utilizes the
@StatisticsModificationLevelparameter, added 2018-06-16 - That parameter is currently set to 5, and you may need to change that depending on your environement
There are some things you’ll need to change in the script, if you’re doing anything really custom:
- It targets the master database
- It’s owned by the sa account
- It’s set to run at midnight
- It has no failure emails or alerts set up
This is a very vanilla starting place. It’s up to you to make it yours.
To report any issues with Ola’s scripts, head over to this GitHub repo.
To get the Agent Job script, head over to my GitHub repo
Thanks for reading!
Going Further
If this is the kind of SQL Server stuff you love learning about: these days I have AI do the annoying stuff for me. My new video course teaches you to work the same way, and I teach whole teams in a one-day workshop. Someone still has to know enough SQL Server to keep the robots in check, and that’s what my training is for.
Great script!
Any specific reason for using cmdexec instead of transact-sql type for job’s step ?
Thanks,
Have look at the way Ola calls his other scripts.
How the hell did I miss this?
Damn.
I was setting up a new database instance and was looking for the tweaks to Ola’s scripts and rumbled across this.
Amazing that it runs so quick when there’s no data.
Users ruin everything.
Next thing you know the bastards will want to query the data too.
The noive!