Comprobar fragmentación, en la primera columna proporciona la Querry para desfragmentar los indices:
WITH INDICES (BD, INDICETIPO, FRAGMENTACION, INDICE, TABLA) AS ( SELECT DBS.NAME BASEDEDATOS, PS.INDEX_TYPE_DESC, PS.AVG_FRAGMENTATION_IN_PERCENT, IND.NAME INDICE, TAB.NAME TABLA FROM SYS.DM_DB_INDEX_PHYSICAL_STATS (DB_ID(), NULL, NULL, NULL, NULL) PS INNER JOIN SYS.DATABASES DBS ON PS.DATABASE_ID = DBS.DATABASE_ID INNER JOIN SYS.INDEXES IND ON PS.OBJECT_ID = IND.OBJECT_ID INNER JOIN SYS.TABLES TAB ON TAB.OBJECT_ID = IND.OBJECT_ID WHERE IND.NAME IS NOT NULL AND PS.INDEX_ID = IND.INDEX_ID AND PS.AVG_FRAGMENTATION_IN_PERCENT > 0) SELECT DISTINCT CASE WHEN FRAGMENTACION > 5 AND FRAGMENTACION <= 30 THEN 'ALTER INDEX ' + INDICE + ' ON ' + TABLA + ' REORGANIZE' WHEN FRAGMENTACION > 30 THEN 'ALTER INDEX ' + INDICE + ' ON ' + TABLA + ' REBUILD' END QUERY, FRAGMENTACION, BD, INDICE, TABLA FROM (SELECT FRAGMENTACION, INDICE, TABLA, BD FROM INDICES WHERE FRAGMENTACION > 5) A ORDER BY FRAGMENTACION DESC