@@ -432,32 +432,32 @@ Key Metrics:
432432
4334331 . ** Analyze Fragmentation** : Use the following query to get detailed fragmentation information.
434434
435- ``` sql
436- SELECT
437- S .name AS ' Schema' ,
438- T .name AS ' Table' ,
439- I .name AS ' Index' ,
440- I .type_desc AS ' Index Type' ,
441- DDIPS .index_type_desc AS ' Index Level' ,
442- DDIPS .alloc_unit_type_desc AS ' Allocation Unit Type' ,
443- DDIPS .avg_fragmentation_in_percent AS ' Fragmentation (%)' ,
444- DDIPS .page_count AS ' Page Count' ,
445- (DDIPS .page_count * 8 / 1024 ) AS ' Index Size (MB)'
446- FROM
447- sys .dm_db_index_physical_stats (DB_ID(), NULL , NULL , NULL , ' DETAILED' ) AS DDIPS
448- INNER JOIN
449- sys .tables T ON T .object_id = DDIPS .object_id
450- INNER JOIN
451- sys .schemas S ON T .schema_id = S .schema_id
452- INNER JOIN
453- sys .indexes I ON I .object_id = DDIPS .object_id
454- WHERE
455- DDIPS .index_id > 0
456- ORDER BY
457- DDIPS .avg_fragmentation_in_percent DESC ;
458- ```
459-
460- <img width =" 550 " alt =" image " src =" https://github.com/user-attachments/assets/78a0afbb-c110-4a66-8ebd-0c79ef30485f " />
435+ ``` sql
436+ SELECT
437+ S .name AS ' Schema' ,
438+ T .name AS ' Table' ,
439+ I .name AS ' Index' ,
440+ I .type_desc AS ' Index Type' ,
441+ DDIPS .index_type_desc AS ' Index Level' ,
442+ DDIPS .alloc_unit_type_desc AS ' Allocation Unit Type' ,
443+ DDIPS .avg_fragmentation_in_percent AS ' Fragmentation (%)' ,
444+ DDIPS .page_count AS ' Page Count' ,
445+ (DDIPS .page_count * 8 / 1024 ) AS ' Index Size (MB)'
446+ FROM
447+ sys .dm_db_index_physical_stats (DB_ID(), NULL , NULL , NULL , ' DETAILED' ) AS DDIPS
448+ INNER JOIN
449+ sys .tables T ON T .object_id = DDIPS .object_id
450+ INNER JOIN
451+ sys .schemas S ON T .schema_id = S .schema_id
452+ INNER JOIN
453+ sys .indexes I ON I .object_id = DDIPS .object_id
454+ WHERE
455+ DDIPS .index_id > 0
456+ ORDER BY
457+ DDIPS .avg_fragmentation_in_percent DESC ;
458+ ```
459+
460+ < img width= " 550" alt= " image" src= " https://github.com/user-attachments/assets/78a0afbb-c110-4a66-8ebd-0c79ef30485f" / >
461461
4624622 . ** Rebuild or Reorganize Indexes** :
463463
0 commit comments