SQL Managed Instance Maintenance: Best Practices Alex, 30 May 202529 April 2025 SQL Managed Instance brings the benefits of SQL Server to a fully managed cloud environment. But without proper upkeep, performance drops, costs spike, and risk increases. So how do you keep it clean, fast, and reliable? By building a maintenance routine that targets the key stress points before they become bottlenecks. 1. Automate Index and Statistics Maintenance Performance often hinges on indexes and statistics. Fragmented indexes slow down queries. Outdated stats mislead the optimizer. What to do: Schedule index rebuilds or reorganizations based on fragmentation thresholds. Run sp_updateStats regularly, especially after large data modifications. Use Azure Automation or Elastic Jobs to orchestrate these tasks. Pro tip: Avoid blanket rebuilds. Prioritize high-impact tables with large row counts or frequent access. 2. Review and Adjust DTU or vCore Sizing Overpaying for unused capacity is wasteful. Under-provisioning leads to throttling and timeouts. Steps to take: Monitor CPU, I/O, and memory usage using Query Store and built-in metrics. Identify patterns. Is your workload bursty? Consider auto-scaling options. Right-size based on actual demand instead of projections. Tip: Set alerts on CPU or storage thresholds. React before users complain. 3. Optimize TempDB Usage TempDB often acts as a silent performance killer. It’s used for sorts, joins, temporary objects, and versioning. Recommendations: Reduce excessive use by tuning queries that rely heavily on sorts or large temp tables. Track version store cleanup. Long-running transactions can bloat TempDB. Enable Memory-Optimized TempDB Metadata if using General Purpose or Business Critical tiers. 4. Schedule Regular Integrity Checks Corruption doesn’t always announce itself. Skipping DBCC CHECKDB is risky, even in a managed instance. Run these at low-traffic periods: DBCC CHECKDB for full consistency checks. DBCC CHECKTABLE for critical tables if time is constrained. Automate execution using SQL Agent Jobs or Azure Automation. Log results for traceability. 5. Apply Maintenance Windows Strategically Azure lets you control when patching and updates occur. Use this. To do: Set a maintenance window during your lowest-usage period. Avoid stacking other maintenance (like index rebuilds) in the same slot. Monitor for changes post-patch, especially on performance baselines. 6. Monitor Long-Running and Blocked Queries Ignoring blocking chains causes slowdowns that ripple across the system. Actions: Enable Query Store and track regressions over time. Capture sys.dm_exec_requests and sys.dm_tran_locks snapshots. Investigate deadlocks and blocking sessions regularly. Fix the root cause, not just the symptoms. Index tuning, query rewriting, or schema adjustments often help. 7. Archive and Purge Data Old data hurts performance if left unchecked. Keep your databases lean. Approach: Define retention policies by table or schema. Use partitioning or filtered indexes to target hot vs. cold data. Schedule data archival or purging with rollback-safe procedures. 8. Encrypt and Audit Security isn’t a one-time setup. Regular checks matter. Ongoing tasks: Rotate encryption keys periodically. Review audit logs for unusual access or failed logins. Validate firewall rules and endpoint configurations. 9. Test Restore Scenarios Backups mean nothing if you can’t restore them under pressure. Checklist: Run point-in-time restore tests quarterly. Validate backup retention matches recovery objectives. Check if backups cover system objects like logins and jobs. 10. Document and Reassess Regularly Maintenance isn’t static. Applications evolve. So should your routines. Keep these current: Runbooks for automation steps. Contacts and escalation paths. Configuration notes (service tier, backup retention, maintenance windows). Review quarterly, or after major updates or migrations. SQL Managed Instance doesn’t run itself. But a smart, lightweight maintenance strategy makes it feel like it does. Keep things lean, logged, and predictable. That’s how you stretch performance, avoid surprises, and make downtime a non-event. Cloud & Infrastructure