{"name":"Sort warnings (last hour)","description":"<p>This metric measures the number of sort warnings events that occurred in the last hour. Sort warning operations that do not fit into memory can degrade query and server performance because multiple passes over the data are required to sort the data. It is important to optimize queries by removing them.<\/p>\r\n\r\n<p>For more information, see <a href=\"http:\/\/www.simple-talk.com\/sql\/learn-sql-server\/showplan-operator-of-the-week---sort\/\">http:\/\/www.simple-talk.com\/sql\/learn-sql-server\/showplan-operator-of-the-week---sort\/<\/a>.<\/p>\r\n\r\n<p>Note: This metric relies on SQL Server default trace. If this is not enabled, the metric will not work.<\/p>","tsql":"DECLARE @Str NVARCHAR(MAX);\r\n\r\nSELECT @Str = CONVERT(NVARCHAR(MAX), Value)\r\n  FROM :: FN_TRACE_GETINFO(DEFAULT) AS Tab\r\n  WHERE Tab.Property = 2\r\n    AND Traceid = 1;\r\n \r\nSELECT COUNT(*) AS Cnt\r\n  FROM FN_TRACE_GETTABLE(@Str, DEFAULT) AS trace \r\n  INNER JOIN sys.trace_events te\r\n  ON te.trace_event_id = trace.EventClass\r\n  WHERE te.name LIKE 'Sort Warnings'\r\n    AND trace.StartTime >= DATEADD(hh, -1, GETDATE());\r\n","instances":true,"frequency":3600,"databases":{"mode":1},"rateofchange":false,"metricenabled":true,"alertname":"Sort warnings","alertdescription":"<p>This alert is raised when the number of sort warnings events that occurred in the last hour goes above a specified threshold. Sort warning operations that do not fit into memory can degrade query and server performance because multiple passes over the data are required to sort the data. It is important to optimize queries by removing them.<\/p>\r\n\r\n<p>For more information, see <a href=\"http:\/\/www.simple-talk.com\/sql\/learn-sql-server\/showplan-operator-of-the-week---sort\/\">http:\/\/www.simple-talk.com\/sql\/learn-sql-server\/showplan-operator-of-the-week---sort\/<\/a>.<\/p>","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":50},"_thresholds_medium":{"selected":true,"value":10},"_thresholds_low":{"selected":true,"value":0},"name_comment":"Note: This metric relies on SQL Server default trace. If this is not enabled, the metric will not work.","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.","targetentitytype":0}