Ver fragmentación de indices de tablas

https://blogs.msdn.microsoft.com/dynamics_latam/2010/09/27/cmo-conocer-el-porcentaje-de-fragmentacin-para-los-ndices-en-tablas-de-microsoft-dynamics-ax/

  1. SELECT  t4.name AS [schema_name]
  2.    ,       t3.name AS TABLE_NAME
  3.    ,       t2.name AS index_name
  4.    ,  t1.object_id
  5.    ,  t1.index_id
  6.    ,  t1.partition_number
  7.    ,  t1.index_type_desc
  8.    ,  t1.avg_fragmentation_in_percent
  9.    ,  t1.avg_fragment_size_in_pages
  10.    ,  t1.page_count
  11.    FROM sys.dm_db_index_physical_stats(db_id(),NULL,NULL,NULL,'LIMITED' ) t1
  12.    INNER JOIN sys.objects t3 ON (t1.object_id = t3.object_id)
  13.    INNER JOIN sys.schemas t4 ON (t3.schema_id = t4.schema_id)
  14.    INNER JOIN sys.indexes t2 ON (t1.object_id = t2.object_id AND  t1.index_id = t2.index_id )
  15.    WHERE index_type_desc <> 'HEAP'
  16.    ORDER BY t4.name,t3.name,t2.name,partition_number

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *