SQL: Instruçao para identificar quais indices estão fragmentados
Software: DIVERSOS | Grupo: BANCO DE DADOS | Prioridade: MÉDIA
Solução
Causa:
Necessidade de identificar quais indices do banco de dados SQL estão com fragmentaçao mais alta
Solução:
Select Top 30 Tabela = O.name, Indice = I.name, IPS.avg_fragmentation_in_percent, IPS.Page_Count, IUS.* From sys.dm_db_index_usage_stats IUS Join sys.objects O on (O.object_id = IUS.object_id) Join sys.indexes I on (I.object_id = IUS.object_id) and (I.index_id = IUS.index_id) Join sys.dm_db_index_physical_stats(DB_ID('Nome_do_banco'), null, null, null, null) IPS on (IPS.object_id = IUS.object_id) and (IPS.index_id = IUS.index_id) Where (IPS.avg_fragmentation_in_percent > 30) Order by (IPS.avg_fragmentation_in_percent ) desc
Tags: indice fragmentado, indices fragmentados