标签:查询 blog 一般来说 percent 并行 pdb report 多个 步骤
Declare @dbid int
Select @dbid=DB_ID()
SELECT DB_NAME(ps.database_id) AS [Database Name], OBJECT_NAME(ps.OBJECT_ID) AS [Object Name],
i.name AS [Index Name], ps.index_id, ps.index_type_desc, ps.avg_fragmentation_in_percent,
ps.fragment_count, ps.page_count, i.fill_factor, i.has_filter, i.filter_definition
FROM sys.dm_db_index_physical_stats(@dbid,NULL, NULL, NULL,null) AS ps
INNER JOIN sys.indexes AS i WITH (NOLOCK)
ON ps.[object_id] = i.[object_id]
AND ps.index_id = i.index_id
WHERE ps.database_id = DB_ID()
AND ps.index_type_desc <> ‘HEAP‘
AND ps.page_count > 2500
ORDER BY ps.avg_fragmentation_in_percent DESC OPTION (RECOMPILE);
alter index index_name
on table_name
rebuild
with(online = on ,sort_in_tempDB = on , maxdop = 最大并行度);
go
标签:查询 blog 一般来说 percent 并行 pdb report 多个 步骤
原文地址:http://www.cnblogs.com/leohahah/p/7652410.html