索引的正常使用對於軟件的性能相當重要。sql
能夠經過DMV,DMF檢查缺失索引狀況。性能
--獲取缺失索引語句。 SELECT top 100 mid.index_handle, equality_columns, inequality_columns, included_columns, statement, avg_total_user_cost, avg_user_impact FROM sys.dm_db_missing_index_details as mid inner join sys.dm_db_missing_index_groups mig on mig.index_handle = mid.index_handle inner join sys.dm_db_missing_index_group_stats migs on mig.index_group_handle = migs.group_handle order by avg_total_user_cost desc
索引也並非越多越好,合理的使用方能達到性能最佳。spa
對於上述幾個DMV列詳情等參考微軟 SQL文檔 code
https://docs.microsoft.com/zh-cn/sql/relational-databases/system-dynamic-management-views/sys-dm-db-missing-index-details-transact-sql?view=sql-server-ver15server