SQL Server: Stop Defragmenting! The Auto Index Compaction Feature That Changes Everything
🔥 Stop Defragmenting indexes: Auto Index Compaction feature preview in SQL Server – This Feature will Kills Index Maintenance Jobs!
Hi SQL Server guys,
In the previous post we analyzed performance improvements in SQL Server 2025 CU3 and uncovered hidden optimizations that nobody talks about.
👉 If you missed it, check it out here:
SQL Server 2025 CU3 – The Hidden Performance Fix Nobody Talks About
In this post instead we will introduce an amazing news in the SQL Server world, i call Auto Index Compaction feature.
🚀 Introducing Automatic Index Compaction
Automatic index compaction is a new built-in feature in the SQL Server engine that compacts indexes in the background with minimal overhead.
No jobs. No maintenance plans. No late-night rebuild scripts.
Just… the engine doing the job for you.
⚡ Executive Summary
- Indexes are compacted automatically in background
- Works continuously as data changes
- Reduces storage, I/O, CPU and memory usage
- No need for index rebuild/reorganize jobs
- Improves query performance
💡 This is NOT about fragmentation anymore. It's about page density.
📌 Where is this available?
⚠️ This feature is currently in preview and available only on:
- Azure SQL Database
- Azure SQL Managed Instance (Always-up-to-date policy)
- SQL Database in Microsoft Fabric
⚙️ How to Enable It
ALTER DATABASE [your_database] SET AUTOMATIC_INDEX_COMPACTION = ON;
Disable it:
ALTER DATABASE [your_database] SET AUTOMATIC_INDEX_COMPACTION = OFF;
🧠 How It Works (Simple Explanation)
As data changes (INSERT / UPDATE / DELETE), SQL Server:
- Finds partially empty pages
- Moves rows to fill them
- Deletes empty pages
👉 Result: same data, fewer pages.
And fewer pages means:
- Less I/O
- Less memory usage
- Less CPU
- Faster queries
📊 Real Impact (Why This Is Huge)
Microosoft published the following results. We will test when soon, with a real benchmark as usually!
After a write-heavy workload:
- Logical reads exploded from 25 → 1610
- Page density dropped from 99% → 52%
- Pages increased massively
Then automatic compaction kicked in:
- Logical reads dropped ~98%
- Page density went back ~96%
- Pages reduced dramatically
🔥 All of this WITHOUT any manual intervention.
⚖️ Compaction vs Rebuild vs Reorganize
| Feature | Compaction | Rebuild | Reorganize |
|---|---|---|---|
| Scope | Only modified pages | All pages | All pages |
| Overhead | Very low | High | Medium |
| Automation | Automatic | Manual | Manual |
| Fragmentation | Not reduced | Reduced | Reduced |
| Page Density | Improved | Improved | Improved |
⚠️ Important Considerations
- Slight increase in CPU (low single-digit %)
- Possible increase in transaction log writes
- Very short page-level locks (milliseconds)
- Does NOT update statistics
💡 Key Insight
Keep in mind, for most workloads, page density matters more than fragmentation.
This completely changes how we should think about index maintenance.
🎯 Final Thoughts
This feature is a paradigm shift.
We are moving from:
- Manual maintenance
- Scheduled jobs
- Heavy rebuild operations
To:
- Autonomous optimization
- Continuous background tuning
- Minimal overhead

Comments
Post a Comment