Most devs rebuild indexes far too often.
✔ What Matters
-
📉 Fragmentation < 30% → ignore
-
🔄 30–80% → reorganize
-
🔨 > 80% → rebuild
⚡ Better Approach
Use sys.dm_db_index_physical_stats to target heavy tables only.
SELECT index_type_desc, avg_fragmentation_in_percent FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'LIMITED');
💡 Pro Tip
“Rebuild everything nightly” is anti-pattern — kills IO.
