USE MasivEmail
SELECT
OBJECT_NAME(ips.object_id) AS object_name
,si.name AS index_name
,ROUND(ips.avg_fragmentation_in_percent,2) AS fragmentation
,ips.page_count AS pages
,ROUND(ips.avg_page_space_used_in_percent,2) page_density
FROM sys.dm_db_index_physical_stats (
DB_ID(N'MasivEmail')
,NULL
,NULL
,NULL
,N'DETAILED') ips
CROSS APPLY sys.indexes si
WHERE
si.object_id=ips.object_id
AND si.index_id=ips.index_id
AND ips.index_level=0
AND ips.alloc_unit_type_desc=N'IN_ROW_DATA'
--Verificar el factor de relleno del indice
SELECT
s.name AS scheme_name
,o.name AS object_name
,i.name AS index_name
,i.fill_factor
FROM sys.indexes AS i
JOIN sys.objects AS o ON i.object_id=o.object_id
JOIN sys.schemas AS s ON o.schema_id=s.schema_id
WHERE o.is_ms_shipped = 0
--Reconstruir el indice y setear el fillfacto
ALTER INDEX NombreIndice ON NombreTabla REBUILD
WITH (FILLFACTOR = 70)
--Reconstruir el indice y setear el fillfacto online con espera
ALTER INDEX NombreIndice ON NombreTabla REBUILD
WITH (FILLFACTOR = 70, ONLINE=ON(
WAIT_AT_LOW_PRIORITY(
MAX_DURATION=1 MINUTES,ABORT_AFTER_WAIT=SELF
)
)
);
No hay comentarios:
Publicar un comentario