{"name":"Indexes with excessive writes","description":"<p>This metric measures the total number of indexes per database, where the number of writes exceed the number of reads. It provides a general indicator of possible performance factors affecting queries in your database.<\/p>\r\n\r\n<p>If indexes are being updated with new data more often than they are being used in query plans, they can cause performance issues during write-heavy operations (INSERT, UPDATE, and DELETE statements), while adding little or no benefit to read operations.<\/p>\r\n\r\n<p><strong>Guideline values: <\/strong>The ideal value for this metric should be 0, but not every bad index should be dropped. There may be some indexes which are used for occasional (but important) queries. This metric should be used to provide insight into the overall indexing strategy.<\/p>\r\n\r\n<p><strong>Possible solutions:<\/strong> If this value indicates the need for further investigation, the following query can help identify indexes that may be candidates for adjustment or elimination:<\/p>\r\n<pre class=\"sql\">SELECT  OBJECT_NAME(s.object_id), i.name, i.type_desc\r\n\r\nFROM    sys.dm_db_index_usage_stats s WITH ( NOLOCK )\r\n\r\nJOIN sys.indexes i WITH (NOLOCK) ON s.index_id = i.index_id\r\n\r\nAND s.object_id = i.object_id\r\n\r\nWHERE   OBJECTPROPERTY(s.[object_id], 'IsUserTable') = 1\r\n\r\nAND s.database_id = DB_ID()\r\n\r\nAND s.user_updates &gt; ( s.user_seeks + s.user_scans + s.user_lookups )\r\n\r\nAND s.index_id &gt; 1\r\n<\/pre>\r\n<p><strong>More information:<\/strong><\/p>\r\n\r\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms191195(v=sql.105).aspx\">General Index Design Guidelines<\/a>","tsql":"\t\r\nSELECT  COUNT(*)\r\nFROM    sys.dm_db_index_usage_stats s WITH ( NOLOCK )\r\nWHERE   OBJECTPROPERTY(s.[object_id], 'IsUserTable') = 1\r\n        AND s.database_id = DB_ID()\r\n        AND s.user_updates > ( s.user_seeks + s.user_scans + s.user_lookups )\r\n        AND s.index_id > 1","instances":true,"frequency":60,"databases":{"mode":0},"rateofchange":false,"metricenabled":true,"alertname":"High Write Indexes > 0","alertdescription":"This alert is raised when the number of writes in a database index exceeds the number of reads. The following query can help identify indexes that may be candidates for adjustment or elimination:<\/p>\r\n<pre class=\"sql\">SELECT  OBJECT_NAME(s.object_id), i.name, i.type_desc\r\n\r\nFROM    sys.dm_db_index_usage_stats s WITH ( NOLOCK )\r\n\r\nJOIN sys.indexes i WITH (NOLOCK) ON s.index_id = i.index_id\r\n\r\nAND s.object_id = i.object_id\r\n\r\nWHERE   OBJECTPROPERTY(s.[object_id], 'IsUserTable') = 1\r\n\r\nAND s.database_id = DB_ID()\r\n\r\nAND s.user_updates &gt; ( s.user_seeks + s.user_scans + s.user_lookups )\r\n\r\nAND s.index_id &gt; 1\r\n<\/pre>\r\n<p><strong>More information:<\/strong><\/p>\r\n\r\n<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms191195(v=sql.105).aspx\">General Index Design Guidelines<\/a><\/p><\/pre>","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":false},"_thresholds_medium":{"selected":true,"value":5},"_thresholds_low":{"selected":true,"value":1},"alertdetailquery":"SELECT CAST(STRING_AGG(     detail, ', ' ) WITHIN GROUP (ORDER BY write_read_ratio DESC) AS NVARCHAR(MAX)) FROM (     SELECT TOP 10         OBJECT_SCHEMA_NAME(s.[object_id]) + '.' + OBJECT_NAME(s.[object_id]) + '.' + ISNULL(i.name, '<unnamed>')         + ' (writes: ' + CAST(s.user_updates AS VARCHAR(20))         + ', reads: ' + CAST(s.user_seeks + s.user_scans + s.user_lookups AS VARCHAR(20)) + ')' AS detail,         CASE WHEN (s.user_seeks + s.user_scans + s.user_lookups) = 0 THEN s.user_updates              ELSE s.user_updates \/ (s.user_seeks + s.user_scans + s.user_lookups)         END AS write_read_ratio     FROM sys.dm_db_index_usage_stats s WITH (NOLOCK)     INNER JOIN sys.indexes i ON s.object_id = i.object_id AND s.index_id = i.index_id     WHERE OBJECTPROPERTY(s.[object_id], 'IsUserTable') = 1     AND s.database_id = DB_ID()     AND s.user_updates > (s.user_seeks + s.user_scans + s.user_lookups)     AND s.index_id > 1     ORDER BY write_read_ratio DESC ) AS top_indexes;","targetentitytype":0}