SMT 1.0 development finished
by Michal Tinthofer on 30/10/2020We just finished second major SMT development in 2020
Read moreIn the world of database administration, index maintenance is a necessary evil. Done right, it keeps your queries snappy; done wrong, it becomes a resource-hungry monster that eats your maintenance window alive. Recently, we faced a challenge where our SQL Agent job wasn't just hungry... it was failing consistently, with runtimes occasionally exceeding 15 hours.
Here is the story of how we moved from a crumbling 15-hour process to a streamlined, stable system.
Phase 1: Divide and Conquer
Our first instinct was to handle the sheer volume of data by splitting the workload. We identified the two largest tables in the database and gave them their own dedicated job. Everything else was handled by a second job.
Phase 2: Identifying the Conflict Zones
Splitting by size wasn't enough; we had to split by "behavior." By analyzing the logs, we identified specific objects that were frequently involved in deadlocks.
We created a third job specifically for these problematic objects and shifted its execution to a different time slot.
Phase 3: The "Aha!" Moment – Hunting the Initialization Lag
When a job takes 6 hours, you usually look at the data movement. However, we dug deeper and found something shocking: The maintenance initialization was taking 4–5 hours before a single index was even touched.
Because the database contained a massive number of tables, the standard scripts were spending hours just "thinking" about what to do.
Phase 4: Optimizing the Best in the Business
Most of us rely on Ola Hallengren’s legendary dbo.IndexOptimize procedure. It is the industry standard for a reason, but even the best tools need a tune-up for extreme edge cases.
To handle our specific "huge table count" scenario, we modified the procedure to create a specialized version: IndexOptimize_OptimizedForLargeDB.
The impact was immediate and dramatic:
Key Takeaways for DBAs
By moving from a "one-size-fits-all" approach to a specialized, optimized procedure, we turned a failing 15-hour marathon into a stable, high-speed sprint which doesn’t take longer than an hour.
Michal is a technically proficient SQL Server Specialist with a proven track record in resolving incidents and implementing changes within large-scale database infrastructures, ensuring maximum availability of services. Concurrently, as a Digital Content and Marketing Specialist, his priority is building strong online brand identities through strategic communication and creative storytelling. He consistently seeks new ways to enhance digital interaction, believing quality digital communication is key to success in today's connected world.