Automating index and statistics maintenance
Version:
For optimal performance, perform maintenance daily during off peak times. At a minimum, perform weekly.
Ola Hallengren scripts (on-prem and IaaS)
-
Download from: https://ola.hallengren.com
-
Run MaintenanceSolution.sql to install jobs:
- IndexOptimize
- UpdateStatistics
- DatabaseIntegrityCheck
-
Schedule using SQL Agent
Azure runbooks (PaaS)
-
Create Azure Automation Account
-
Add PowerShell Runbook that:
- Connects to Azure SQL
- Executes Olaâs procedures
-
Schedule it (daily/weekly)
-
Grant permission via managed identity or connection string
Monitoring execution and failures
- Use Azure Automation dashboard
- Enable alerts on job failures
- Log job output for troubleshooting
If you have suggestions for improving this article, let us know!