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
@StatisticsModificationLevel
parameter, 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, you’ll love my training. I’m offering a 75% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that and need to solve performance problems quickly.
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!