select migs.avg_total_user_cost*(migs.avg_user_impact/ 100.0) *(migs.user_seeks + migs.user_scans) asimprovement_measure, 'create index[missing_index_' + convert(varchar, mig.index_group_handle) + '_' + convert(varchar, mid.index_handle) + '_' + left(parsename(mid.statement, 1), 32) + ']' + ' on ' + mid.statement + ' (' + isnull(mid.equality_columns,'') + case when mid.equality_columns is not null and mid.inequality_columnsis not null then ',' else '' end + isnull(mid.inequality_columns, '') + ')' + isnull(' include (' + mid.included_columns+ ')', '') ascreate_index_statement, migs.*, mid.database_id, mid.[object_id] from sys.dm_db_missing_index_groups mig inner join sys.dm_db_missing_index_group_statsmigs on migs.group_handle= mig.index_group_handle inner join sys.dm_db_missing_index_detailsmid on mig.index_handle= mid.index_handle where migs.avg_total_user_cost *(migs.avg_user_impact /100.0) *(migs.user_seeks + migs.user_scans) > 10 order by migs.avg_total_user_cost* migs.avg_user_impact*(migs.user_seeks + migs.user_scans) desc
SQL语句实现查询并自动创建Missing Index
•
生活家
赞 (0)
SQL Server中使用Trigger监控存储过程更改脚本实例
上一篇
2022年3月22日
SQL语句实现查询SQL Server服务器名称和IP地址
下一篇
2022年3月22日