{"name":"Percentage of fragmented indexes","description":"<p><strong>Explanation:<\/strong> This is a general indicator of performance problems. Index fragmentation can affect the rate of return for moderate to large tables. If multiple indexes are fragmented throughout the database, then an index maintenance strategy needs to be evaluated.<\/p>\r\n<p><strong>Guideline values:<\/strong> The ideal value for this metric is less than 5%; this metric counts the number of moderate to large indexes (page values &gt; 100) with fragmentation levels greater than 5%, and then divides that number by the number of indexes in the database. This percentage may increase throughout the day as data is loaded into your database, but it will shrink when indexes are rebuilt or reorganized. This metric does not identify specific performance problems with a specific index, but should be used to obtain a general idea of how well your index maintenance strategy addresses overall problems.<\/p>\r\n<p><strong>Possible solutions:<\/strong> If this value indicates an increased amount of index fragmentation throughout your database, you may need to fine-tune your index maintenance plans.  Indexes may need to be redesigned, or rebuilt more frequently.<\/p>\r\n<p><strong>More information:<\/strong><\/p>\r\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms188917\"><strong>sys.dm_db_index_physical_stats (Transact-SQL)<\/strong><\/a><\/p>\r\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms189858.aspx\"><strong>Reorganize and Rebuild Indexes<\/strong><\/a><\/p>","tsql":"DECLARE @frag DECIMAL(10, 2) ,\r\n    @tot INT;\r\n  \r\nSELECT  @frag = COUNT(*)\r\nFROM    sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL,\r\n                                       NULL, 'LIMITED') ps\r\nWHERE   ps.avg_fragmentation_in_percent >= 5\r\n        AND ps.page_count > 100\r\n        AND OBJECTPROPERTY(ps.[object_id], 'IsUserTable') = 1;\r\n \r\nSELECT  @tot = COUNT(*)\r\nFROM    sys.indexes i\r\nWHERE   OBJECTPROPERTY(i.[object_id], 'IsUserTable') = 1;\r\n \r\nSELECT  @tot = CASE WHEN @tot = 0 THEN 1\r\n                    ELSE @tot\r\n               END;\r\n \r\nSELECT  CAST(( @frag \/ @tot ) AS DECIMAL(10, 2)) * 100;\r\n","instances":true,"frequency":86400,"databases":{"mode":0},"rateofchange":false,"metricenabled":true,"alertname":"Increased % of fragmented indexes","alertdescription":"<p><strong>Explanation:<\/strong> This alert is raised when index fragmentation goes above the threshold specified. This is a general indicator of performance problems. Index fragmentation can affect the rate of return for moderate to large tables. If multiple indexes are fragmented throughout the database, then an index maintenance strategy needs to be evaluated.<\/p>\r\n\r\n<p>The ideal value for the metric on which this alert is based is less than 5%; the metric counts the number of moderate to large indexes (page values &gt; 100) with fragmentation levels greater than 5%, and then divides that number by the number of indexes in the database. This percentage may increase throughout the day as data is loaded into your database, but it will shrink when indexes are rebuilt or reorganized. This metric does not identify specific performance problems with a specific index, but should be used to obtain a general idea of how well your index maintenance strategy addresses overall problems.<\/p>\r\n\r\n<p><strong>Possible solutions:<\/strong> If this value indicates an increased amount of index fragmentation throughout your database, you may need to fine-tune your index maintenance plans. Indexes may need to be redesigned or rebuilt more frequently.<\/p>\r\n\r\n<p><strong>More information: <\/strong><\/p>\r\n\r\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms188917\"><strong>sys.dm_db_index_physical_stats (Transact-SQL)<\/strong><\/a><\/p>\r\n\r\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms189858.aspx\"><strong>Reorganize and Rebuild Indexes<\/strong><\/a><\/p>","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":15},"_thresholds_medium":{"selected":true,"value":10},"_thresholds_low":{"selected":true,"value":5},"thresholds_comment":"Note: These thresholds are intended as guideline values. If they seem too high or too low for your environment, replace them with values more suited to your server performance.","frequency_comment":"Note: Excessively large databases may not return data within an acceptable time frame, so you may need to adjust the collection frequency of this metric from 1 minute to 5 or 10 minutes.","targetentitytype":0}